0
0
TensorFlowml~12 mins

Input shape specification in TensorFlow - Model Pipeline Trace

Choose your learning style9 modes available
Model Pipeline - Input shape specification

This pipeline shows how data is prepared and fed into a TensorFlow model by specifying the input shape correctly. The input shape tells the model what size and format the data will be.

Data Flow - 3 Stages
1Raw data
1000 rows x 28 x 28 pixelsCollect grayscale images of handwritten digits1000 rows x 28 x 28 pixels
Image of digit '5' as 28x28 pixel grid
2Reshape for model input
1000 rows x 28 x 28 pixelsAdd channel dimension to match model input shape1000 rows x 28 x 28 x 1
Image reshaped to 28x28 pixels with 1 channel
3Model input layer
28 x 28 x 1Specify input shape in TensorFlow model as (28, 28, 1)28 x 28 x 1
Input layer expects shape (28, 28, 1)
Training Trace - Epoch by Epoch
Loss
0.5 |****
0.4 |***
0.3 |**
0.2 |*
0.1 |
    +---------
     1 2 3 Epochs
EpochLoss ↓Accuracy ↑Observation
10.450.82Model starts learning with moderate accuracy
20.300.90Loss decreases and accuracy improves
30.220.93Model converges with good accuracy
Prediction Trace - 4 Layers
Layer 1: Input layer
Layer 2: Convolutional layer
Layer 3: Flatten layer
Layer 4: Dense output layer
Model Quiz - 3 Questions
Test your understanding
Why do we add a channel dimension to the input shape?
ATo reduce the image size
BTo match the model's expected input format
CTo increase the number of images
DTo convert images to color
Key Insight
Specifying the correct input shape is essential for the model to understand the data format. Adding the channel dimension for grayscale images ensures compatibility with convolutional layers, enabling the model to learn effectively.