This tutorial explains how to flatten
a input layer in TensorFlow
.
With the use of tf.keras.layers.Flatten
input can be flattened without affecting batch size.
Lets understand flattening
of input with below example
TensorFlow
import tensorflow as tf
tf.keras
.
model = tf.keras.Sequential()
conv2D
layer to the model
model.add(tf.keras.layers.Conv2D(64, 3, 1, input_shape=(3, 64, 64)))
tf.keras.layers.Flatten
print(model.output)
#### Output #####
Tensor("conv2d/BiasAdd:0", shape=(None, 1, 62, 64), dtype=float32)
Flatten
layer to the model for flattening the input
model.add(tf.keras.layers.Flatten())
tf.keras.layers.Flatten
print(model.output)
#### Output ####
Tensor("flatten/Reshape:0", shape=(None, 3968), dtype=float32)
Similar Articles