Architecture, shapes & trainability

Neural Network Parameter Explorer

Build an MLP or CNN. Change its layers and follow every weight, bias, output shape and trainable parameter.

12 min to exploreMachine Learning · Computer Vision
01 / UNDERSTAND

How many parameters does your network actually learn?

Dense connections, convolutional kernels and biases contribute parameters. Freezing changes trainability. Pooling changes shape without adding learned parameters, and flattening can greatly increase the next dense layer's size.

02 / EXPLORE

Make a prediction.
Then move a control.

Architecture → arithmetic

Where do the parameters come from?

Change the architecture. Trace every learned weight and bias.

Each dense neuron connects to every value in the previous layer.

Total parameters26
Trainable26
Frozen0
Select a layer to see its calculation.
LayerInput → output shapeWeightsBiasesTotalTrainableFrozen
Hidden 13 × 4 weights + 4 biases = 16 parameters

Four neurons each learn three weights and one bias.

Parameters are learned numbers.

Output values are activations, not extra parameters. A ReLU, softmax, dropout layer or pooling operation adds no learned parameters. Freezing a layer changes how many parameters can update; it does not remove them.

An educational experiment with illustrative data. The controls run locally in your browser.

03 / SEE THE CODE

The idea,
in Python.

A compact implementation of the core concept. Open the code when you are ready to connect the visual to the algorithm.

Open the core implementation Python ↗
Standalone example · illustrative valuesDownload .py
import torch
from torch import nn

model = nn.Sequential(
    nn.Linear(3, 4, bias=True),  # 3*4 + 4 = 16
    nn.ReLU(),                 # 0 parameters
    nn.Linear(4, 2, bias=True)  # 4*2 + 2 = 10
)
for name, layer in model.named_children():
    total = sum(p.numel() for p in layer.parameters())
    trainable = sum(p.numel() for p in layer.parameters() if p.requires_grad)
    print(name, total, trainable)

# Freeze only the first dense layer.
for parameter in model[0].parameters():
    parameter.requires_grad = False
print("Total:", sum(p.numel() for p in model.parameters()))
print("Trainable:", sum(p.numel() for p in model.parameters() if p.requires_grad))
# Conv2d: out_channels * (in_channels * kH * kW + bias_term).
# Groups=1 in this explorer; MaxPool2d / AvgPool2d have no learned parameters.
04 / TRY IT

Explain the change.
Test your reasoning.

  1. Build a 3 → 4 → 2 dense network with bias and explain its 26 parameters.
  2. Widen the hidden layer. Which two layers change their counts?
  3. Switch to CNN mode, add pooling and compare the final dense layer. Then freeze a layer.
← All visual labsNext: Transfer Learning: Choose What Learns

Find your next idea.

Search across courses, research, projects, and resources.

Ideas, connected.esc to close