2

How I solve this issue

ValueError: Error when checking target: expected conv-decode3 to have shape (None, 14, 300) but got array with shape (6559, 16, 300)

NUM_WORDS = 3
pool_size = 2
x = Input(shape=(16, 300), name="input")
h = x
h = Conv1D(filters=300, kernel_size=NUM_WORDS,
             activation="relu", padding='same', name='Conv1')(h)
h = MaxPooling1D(pool_size=pool_size, name='Maxpool1')(h)
h = Conv1D(filters=150, kernel_size=NUM_WORDS,
             activation="relu", padding='same', name='Conv2')(h)
h = MaxPooling1D(pool_size=pool_size,  name="Maxpool2")(h)
h = Flatten() (h)
h = Dense(10, name='embedding') (h)
y = h
y = Dense(600, activation="relu") (y)
y = Reshape((4, 150)) (y)
y = Conv1D(filters=150, kernel_size=NUM_WORDS,
             activation="relu", padding='same', name='conv-decode1')(y)
y = UpSampling1D(size=pool_size, name='upsampling1')(y)
y = Conv1D(filters=300, kernel_size=NUM_WORDS,
             activation="relu", padding='same', name='conv-decode2')(y)
y = UpSampling1D(size=pool_size, name='upsampling2')(y)


return Model(inputs=x, outputs=y, name='AE'), Model(inputs=x, outputs=h, name='encoder')
Waseem Randhawa
  • 149
  • 2
  • 17

1 Answers1

1

do you still have this problem? Your 1D AE does not contain definition of the layer:conv-decode3

I just added compilation and printed the model - looks good to mee - input shape equals to output shape. Jan

y = UpSampling1D(size=pool_size, name='upsampling2')(y)

autoencoderM = Model(x, y)
myLoss='mean_squared_error'
autoencoderM.compile(optimizer='adadelta', loss=myLoss)

autoencoderM.summary() # will print


Layer (type) Output Shape Param #

input (InputLayer) (None, 16, 300) 0


Conv1 (Conv1D) (None, 16, 300) 270300


. . .


conv-decode2 (Conv1D) (None, 8, 300) 135300


upsampling2 (UpSampling1D) (None, 16, 300) 0

Total params: 621,010