2

I want to build a generator model based on the picture (reference). The picture said that the model is using a 1D-Transposed Convolutional Layer.

generator model

Is that possible to build the model (like in the picture) by using Conv1DTranspose in Keras while the input size is (10x10x1)? If it is possible, could you give some advice on how to perform it in Keras? Thank you.

Before, I tried to build the model. The dimension output seems to be correct, but I used Conv2DTranspose instead of Conv1DTranspose. (please correct me if I am wrong on the implementation especially on the first 4 layers).

def get_mlp():
    in_lat = Input(shape=(100,))
    
    x = Reshape((10,10,1))( in_lat )   
    x = Conv2DTranspose(32, 7, strides=(2,1), padding='same', activation='relu')(x)
    x = Conv2DTranspose(64, 7, strides=(2,1), padding='same', activation='relu')(x)
    x = Conv2DTranspose(128, 7, strides=(2,1), padding='same', activation='relu')(x)
    
    x = Reshape((800,-1))(x)
    x = Conv1D(128, 3, strides=1, padding='same')(x)
    x = Conv1D(64, 3, strides=2, padding='same')(x)
    x = Conv1D(32, 3, strides=2, padding='same')(x)
    
    out = Dense(100, activation='softmax')(x)
    model = Model(in_lat, out)
    
    model.summary()
    return model

Output

Model: "functional_95"
_________________________________________________________________
Layer (type)                 Output Shape              Param #   
=================================================================
input_64 (InputLayer)        [(None, 100)]             0         
_________________________________________________________________
reshape_80 (Reshape)         (None, 10, 10, 1)         0         
_________________________________________________________________
conv2d_transpose_91 (Conv2DT (None, 20, 10, 32)        1600      
_________________________________________________________________
conv2d_transpose_92 (Conv2DT (None, 40, 10, 64)        100416    
_________________________________________________________________
conv2d_transpose_93 (Conv2DT (None, 80, 10, 128)       401536    
_________________________________________________________________
reshape_81 (Reshape)         (None, 800, 128)          0         
_________________________________________________________________
conv1d_47 (Conv1D)           (None, 800, 128)          49280     
_________________________________________________________________
conv1d_48 (Conv1D)           (None, 400, 64)           24640     
_________________________________________________________________
conv1d_49 (Conv1D)           (None, 200, 32)           6176      
_________________________________________________________________
dense_8 (Dense)              (None, 200, 100)          3300      
=================================================================
Total params: 586,948
Trainable params: 586,948
Non-trainable params: 0
furanzup
  • 91
  • 1
  • 8
  • 1
    Looks correct to me. Are you getting any errors? – Tinu Nov 17 '20 at 16:48
  • Hi, thanks for your reply. I did not get any errors when I implemented it. However, I am still not sure about the first 1D-Transposed Layers because I used 2D-Transposed Layers on my code. Do you have any advices for it ? – furanzup Nov 18 '20 at 08:33
  • @FranzP:Check [this](https://stackoverflow.com/questions/44061208/how-to-implement-the-conv1dtranspose-in-keras) and [this](https://www.tensorflow.org/api_docs/python/tf/keras/layers/Conv1DTranspose) – George Nov 18 '20 at 08:44
  • Thanks for the references – furanzup Dec 04 '20 at 17:59

0 Answers0