0
0
TensorFlowml~12 mins

Padding and stride in TensorFlow - Model Pipeline Trace

Choose your learning style9 modes available
Model Pipeline - Padding and stride

This pipeline shows how padding and stride affect the size of images as they pass through a convolutional layer in a neural network. Padding adds extra pixels around the image edges, and stride controls how the filter moves over the image.

Data Flow - 3 Stages
1Input Image
1 image x 28 height x 28 width x 1 channelOriginal grayscale image1 image x 28 height x 28 width x 1 channel
A 28x28 pixel handwritten digit image
2Apply Padding
1 image x 28 height x 28 width x 1 channelAdd 1 pixel zero padding around all edges1 image x 30 height x 30 width x 1 channel
Image now has a 1-pixel black border around it
3Convolution with stride
1 image x 30 height x 30 width x 1 channelApply 3x3 filter with stride 21 image x 14 height x 14 width x 1 channel
Filter moves 2 pixels at a time, reducing size
Training Trace - Epoch by Epoch
Loss
0.7 |****
0.6 |*** 
0.5 |**  
0.4 |*   
0.3 |    
0.2 |    
     1 2 3 4 5 Epochs
EpochLoss ↓Accuracy ↑Observation
10.650.60Model starts learning, loss is high, accuracy low
20.480.75Loss decreases, accuracy improves as model learns features
30.350.85Model captures patterns well, loss drops further
40.280.90Good convergence, accuracy nearing 90%
50.220.93Model stabilizes with low loss and high accuracy
Prediction Trace - 3 Layers
Layer 1: Input Image
Layer 2: Padding
Layer 3: Convolution with stride 2
Model Quiz - 3 Questions
Test your understanding
What effect does adding padding have on the image size before convolution?
ADecreases image size by cropping edges
BDoes not change image size
CIncreases image size by adding pixels around edges
DChanges image colors
Key Insight
Padding helps keep the image size from shrinking too much during convolution, preserving edge details. Stride controls how much the filter moves, affecting output size and computation. Together, they balance detail retention and efficiency in feature extraction.