Aligning the tensor means deleting all but one dimension.
The Flatten layer in Keras changes the shape of the tensor to have a shape equal to the number of elements contained in the tensor.
This is the same as creating a 1d array of elements.
For example, in the VGG16 model, it may be easy for you to understand:
>>> model.summary() Layer (type) Output Shape Param # ================================================================ vgg16 (Model) (None, 4, 4, 512) 14714688 ________________________________________________________________ flatten_1 (Flatten) (None, 8192) 0 ________________________________________________________________ dense_1 (Dense) (None, 256) 2097408 ________________________________________________________________ dense_2 (Dense) (None, 1) 257 ===============================================================
Notice what the shape of the flatten_1 layer is (No, 8192), where 8192 is actually 4 * 4 * 512.
PS, None means a measurement (or dynamic measurement), but you can usually read it as 1. More information can be found in here .
source share