What is the meaning of the "None" in model.summary of KERAS?
None
means this dimension is variable.
The first dimension in a keras model is always the batch size. You don't need fixed batch sizes, unless in very specific cases (for instance, when working with stateful=True
LSTM layers).
That's why this dimension is often ignored when you define your model. For instance, when you define input_shape=(100,200)
, actually you're ignoring the batch size and defining the shape of "each sample". Internally the shape will be (None, 100, 200)
, allowing a variable batch size, each sample in the batch having the shape (100,200)
.
The batch size will be then automatically defined in the fit
or predict
methods.
Other None
dimensions:
Not only the batch dimension can be None
, but many others as well.
For instance, in a 2D convolutional network, where the expected input is (batchSize, height, width, channels)
, you can have shapes like (None, None, None, 3)
, allowing variable image sizes.
In recurrent networks and in 1D convolutions, you can also make the length/timesteps
dimension variable, with shapes like (None, None, featuresOrChannels)
Yes, None
in summary means a dynamic dimension of a batch (mini batch).
This is why you can set any batch size to your model.
The summary()
method is part of TF that incorporates Keras method print_summary()
.