What are these (None,x) values in Keras model visualization?

Question:

rnn model visualized

model = Sequential()

model.add(Embedding(10000, 300, input_length=200))
model.add(LSTM(256, return_sequences=True, dropout=0.5, recurrent_dropout=0.5))
model.add(LSTM(256, dropout=0.5, recurrent_dropout=0.5))
model.add(Dense(4, activation='softmax'))
...

plot_model(model, to_file='rnn.png' ,show_shapes=True, show_layer_names=True)

Why is it like (None,200) and not (200)?

Asked By: LagSurfer

||

Answers:

That is due to the batch size. When you train a model, you can pass through different batch sizes (e.g. 32, 64, …).

This means that for instance, if you train a model with a batch size of 32, the first layer will have a shape of (32, 200) and so on.

When you build the model the input batch size is still not defined. That is why Tensorflow prints None.

Answered By: ebeneditos