Backpropagation › Vectorized Backpropagation
Language AI HandbookAll chapters Backpropagation › Vectorized BackpropagationOne section · Sections in this chapter11 / 20 ↓
Reading tools Definitions & inline links
Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.
Article links
Make inline references clickable
Real implementations work with mini-batches rather than single examples. With a batch of examples, the input is , and all forward and backward computations generalize naturally.
For a linear layer :
- Forward: (matrix multiplication, )
- Backward gradient w.r.t. weights: (result shape )
- Backward gradient w.r.t. input: (result shape )
- Backward gradient w.r.t. bias: (sum over batch dimension)
The bias gradient requires summing over the batch dimension because the same bias vector is added to all examples. This is another example of gradient accumulation: the bias participates in computations (one per example), so its gradient is the sum over all paths.
Vectorized backpropagation improves performance and naturally averaged (or summed, depending on how the loss is normalized) over the batch. A batch gradient descent step moves the parameters in a direction that reduces the average loss across all examples in the batch. With large batches, this average is a better approximation of the true gradient over the full dataset, leading to more stable optimization. With small batches (stochastic gradient descent), the noisier gradient estimate can help escape sharp local minima, which is why SGD with a small batch size often generalizes better than full-batch gradient descent.