Neurons, weights, biases and layers
What it is
A neuron computes z = x·w + b, then usually applies an activation. The weights say how strongly each input contributes; positive and negative weights can support or suppress a feature, while the bias shifts the threshold at which the neuron activates. A layer evaluates many neurons in parallel: for a batch X, Z = XWᵀ + b. The output width is the number of independently learned features that layer can expose to the next layer.
Why it matters
Shapes explain most neural-network bugs. A linear layer with in_features=64, out_features=128 maps (batch, 64) to (batch, 128); its weights are learned, while its dimensions are architectural choices that trade capacity against cost. Once that contract is clear, a matrix multiplication error is not mysterious: either the previous layer emitted the wrong feature width or the next layer declared the wrong input width.
In the real world: Inside a model that predicts whether a customer will click an ad: many small weighted sums stacked in layers.
Visual example
Interactive forward passMove an input slider and follow its contribution through the weighted sum and activation in real time.
Why this matters
A layer is just many copies of this calculation with different learned weights. Seeing the one-neuron arithmetic makes the matrix form feel like a compact notation rather than magic.
Common misconception
Wrong idea: a neuron makes a binary decision by itself.
Correct idea: it produces a continuous value. A network gets its expressive power from many such values, their nonlinearities, and their composition.
import torch.nn as nn
layer = nn.Linear(64, 128)
# input: (batch, 64); output: (batch, 128)Thinking a bias is optional decoration. Without it every neuron's decision boundary is forced through the origin, a needless and often severe restriction.