What is the meaning of the (None, 100) in Output Shape? Is this("None") the Sample number or the hidden dimension?
A None value in the shape of a tensor means that the tensor can be of any size (large than or equal to 1) in that dimension.
Summarize ModelKeras provides a way to summarize a model. The summary is textual and includes information about: The layers and their order in the model. The output shape of each layer. The number of parameters (weights) in each layer.
The input shape In Keras, the input layer itself is not a layer, but a tensor. It's the starting tensor you send to the first hidden layer. This tensor must have the same shape as your training data. Example: if you have 30 images of 50x50 pixels in RGB (3 channels), the shape of your input data is (30,50,50,3) .
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()
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With