๐ CNN-to-Linear Shape Mismatch Visualizer
Watch the image shrink, unfold, and plug in โ glowing green only when the numbers truly match.
๐ How To Use This Lab
Adjust the
Image Size
,
Kernel/Stride/Padding
, and
MaxPool
sliders โ every shape updates live down the pipe.
Watch the block physically
shrink
at each stage, then
unfold
into a flat line at Flatten.
Type a guess into
in_features
โ if it's wrong, the plug shows red and disconnected, just like PyTorch's real error.
Press
โ Auto-Calculate
to snap in_features to the exact correct value and watch the plug glow green.
Flattened = 3136
โ Connected
Input Image
3 ร 28 ร 28
Conv2d
k=3, s=1, p=1
16 ร 28 ร 28
MaxPool2d
pool=2ร2
16 ร 14 ร 14
Flatten
16 ร 14 ร 14 = 3136
nn.Linear Input Socket
๐๏ธ Architecture Parameters
Input Image Size:
28
ร
28
Conv Kernel Size:
3
Conv Stride:
1
Conv Padding:
1
MaxPool Size
2 ร 2
3 ร 3
nn.Linear(in_features =
)
โ Auto-Calculate
๐ PLUGGY
Type a number into in_features โ I'll show you exactly whether it plugs in cleanly.
๐งโ๐ซ PROF. TORCH
in_features must equal out_channels ร H_final ร W_final โ nothing more, nothing less.