The Forward Pass: How Input Flows Through Layers via Matrix Multiplication

~12 min read

The forward pass is just repeated matrix multiplication: each layer's neurons all compute their weighted sums at once as a single matrix-vector product, which is why GPUs (built for matrix math) are so good at running neural networks.

The Forward Pass: How Input Flows Through Layers via Matrix Multiplication is a Pro topic

Sign in, then upgrade to Pro or Power to unlock this topic and the full AI Engineering curriculum.

Key points

  • The forward pass is the process of pushing an input through every layer, in order, to produce the network's output
  • A whole layer's computation is one matrix operation: output = activation(W @ x + b) — equivalent to, but far faster than, per-neuron loops
  • Information flows strictly forward (input toward output) with no loops back — that's why it's called the 'forward' pass
  • Batching stacks many examples into rows of a matrix, computing all their forward passes in one matrix multiplication — a big reason GPUs accelerate training
  • Every deep learning framework (PyTorch, TensorFlow) implements this same chain of matrix multiplications and elementwise activations underneath its convenience API