ValueError: The shape of the input to "Flatten" is not fully defined (Neural Networks)

282 views Asked by At

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?

1

There are 1 answers

0
Dinh Nha Nguyen On

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