-1

I try to using Flatten for my LSTM model, but it doesn't work and getting this error:

ValueError: The shape of the input to "Flatten" is not fully defined (got (None, 450) Make sure to pass a complete "input_shape" or "batch_input_shape" argument to the first layer in your model.

Model:

input_vector_size = kwargs.get('input_vector_size', 128)
dense_size = kwargs.get('dense_size', 20)
timesteps = None
xav_init = tf.contrib.layers.xavier_initializer()
##########

model = Sequential()
model.add(LSTM(int(input_vector_size), input_shape=timesteps,int(input_vector_size)), return_sequences=True))
model.add(SeqSelfAttention(attention_activation='softmax'))
model.add(Flatten())
model.add(Dense(dense_size, activation='sigmoid', kernel_initializer=xav_init))
model.add(Dense(kwargs.get('label_size', 2), activation='sigmoid'))

How do I solve this problem?

2
  • You need another bracket: input_shape=(timesteps, int(input_vector_size)), otherwise the input_shape=timesteps=None Apr 2, 2019 at 6:07
  • Yes i forgot the bracket anw i fixed the code. I should change the timesteps to 1 if i want to use Flatten() @JimmyOnThePage Apr 3, 2019 at 4:06

1 Answer 1

-1

Just for anyone want to know the answer. You should change the input_shape to (1,int(input_vector_size)) to use Flatten

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.