Example Usage of keras.Input
In this section, we have defined a CNN model with an input shape of (28, 28, 1) and a batch size of 3 using TensorFlow’s Keras API. It includes a convolutional layer with 16 filters, a max pooling layer, a flatten layer, and a dense layer with 10 units and a softmax activation function for classification. The shape of the input layer is printed, showing the specified shape and batch size.
from tensorflow import keras
from keras import models, layers
input_layer = keras.layers.Input(shape=(28, 28, 1),batch_size=3)
model = models.Sequential([
layers.Conv2D(16, (3,3)),
layers.MaxPooling2D(pool_size=2),
layers.Flatten(),
layers.Dense(10, activation='softmax'),
])
print("The shape of input layer: ",input_layer.shape)
Output:
The shape of input layer: (3, 28, 28, 1)
- The input layer in Keras is in charge of obtaining and transforming the input data, making it a crucial part of deep learning models.
- The whole neural network architecture depends on the shape of the input data.
- Thus to start with building an efficient neural network, Input layer is necessary.
Keras Input Layer
When deep learning models are built, the foundation step of the model preparation starts with the input layer. Keras Input Layer is essential for defining the shape and size of the input data the model with receive. In this article, we are going to learn more on Keras Input Layer, its purpose, usage and it’s role in model architecture.
Table of Content
- What is Keras Input Layer?
- Key Features of Keras Input Layer
- Syntax of Keras Input Layer
- Example Usage of keras.Input