Neural Network Parameter Explorer
Build an MLP or CNN. Change its layers and follow every weight, bias, output shape and trainable parameter.
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.
Make a prediction.
Then move a control.
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.
Shapes use H × W × C and omit the batch dimension. Convolutions use square kernels, dilation 1 and groups 1. Pooling uses floor output sizes; average pooling includes padded zeros.
| Layer | Input → output shape | Weights | Biases | Total | Trainable | Frozen |
|---|
Four neurons each learn three weights and one bias.
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.
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 ↗
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.Explain the change.
Test your reasoning.
- Build a 3 → 4 → 2 dense network with bias and explain its 26 parameters.
- Widen the hidden layer. Which two layers change their counts?
- Switch to CNN mode, add pooling and compare the final dense layer. Then freeze a layer.