Forward propagation computation
WHY does forward propagation exist?
WHAT problem does it solve? A neural network is a function with millions of tunable knobs (weights). Before we can learn those knobs (backprop), we must be able to compute the prediction for a given input. Forward propagation is that computation — the "run the network" step.
WHY this design (linear + nonlinear)?
- A pure stack of linear layers collapses: — still linear, no matter how deep. So depth would be useless.
- Inserting a nonlinear activation between layers breaks that collapse, letting the network approximate curved, complex functions. This is the whole reason deep nets are powerful.
HOW: building it from first principles
Step 1 — A single neuron
A neuron receives inputs , each with importance , plus a bias .
Why the bias? Without , every neuron's decision boundary must pass through the origin. The bias shifts the activation left/right, giving freedom to fire even when inputs are zero.
Step 2 — Vectorize one layer
Stacking neurons in a layer, each has its own weight row. Collect them:
Why does row of contain neuron 's weights? Because matrix–vector multiply computes each output as a dot product of a row with the input. Row · input — exactly the weighted sum for neuron .
Step 3 — Chain the whole network
With input , repeat for :
The final activation is the prediction. For classification is usually softmax; for regression it's often identity.

Step 4 — Batch form (why we use matrices)
Instead of one input vector, process examples at once as columns of (): The bias () is broadcast across all columns. Why batch? One big matmul uses hardware (GPU) far more efficiently than small ones.
Common activations (and WHY each)
Common hidden activations: ReLU (cheap, no vanishing gradient for ), sigmoid (squashes to ), tanh (squashes to ).
Worked Example 1 — a tiny 2-layer network by hand
Input . Hidden layer (2 units), ReLU: Output layer (1 unit), identity:
Layer 1 pre-activation — Why? Combine inputs with weights + bias:
Layer 1 activation — Why? Apply ReLU (clip negatives to 0):
Layer 2 — Why? Same recipe, identity activation:
Worked Example 2 — softmax output
Logits . Why exponentiate? To turn scores into positive, comparable weights: Why divide by the sum? So the outputs form a probability distribution (). Class 0 is most likely.
Forecast-then-Verify
Common mistakes (Steel-manned)
Recall Explain to a 12-year-old (Feynman)
Imagine a bucket-brigade passing water. Each person grabs water from the people behind them, but they trust some neighbours more than others — so they scoop more from trusted ones (that's the weights). They also always add a fixed splash of their own (the bias). Then they pour it through a funny-shaped funnel that changes how much comes out (the activation). The water gets passed forward person by person until the last person shows the answer. Forward propagation is just water flowing forward through the brigade once.
Flashcards
What are the two operations in one layer's forward pass?
Why must layers have a nonlinear activation?
For a layer with inputs and units, what is the shape of ?
What does the bias term do geometrically?
Why use exponentials in softmax?
What is the pre-activation ?
In batch forward prop, why is the bias broadcast?
Which activation is typical for the output of a classifier vs a regressor?
Why do we prefer batched matrix multiplies over per-sample loops?
Connections
- Activation functions — the nonlinearities that make forward prop expressive.
- Backpropagation — reuses the cached from forward prop to compute gradients.
- Matrix multiplication — the computational engine of each layer.
- Softmax and cross-entropy loss — output activation + how prediction becomes a loss.
- Universal approximation theorem — why one nonlinear hidden layer already gives huge power.
- Vanishing and exploding gradients — downstream consequence of activation choices made here.
Concept Map
Hinglish (regional understanding)
Intuition Hinglish mein samjho
Forward propagation ka matlab bas itna hai: input ko network ke andar aage ki taraf bhejna, layer-by-layer, jab tak prediction na mil jaye. Har layer do kaam karti hai — pehle ek linear step (, yaani inputs ko weights se multiply karke bias add karna), phir ek nonlinear activation (, jaise ReLU ya softmax). Weight batata hai kaunsa input kitna important hai, aur bias ek fixed shift deta hai taaki neuron zero input pe bhi fire kar sake.
Sabse important baat — activation kyun zaroori hai? Agar tum sirf linear layers stack karo, toh poora network end me ek hi linear equation ban jaata hai, chahe kitni bhi layers ho. Nonlinearity hi network ko "curved" aur powerful banati hai. Isliye ReLU/tanh/softmax ko kabhi skip mat karna.
Shapes ka dhyan rakho: agar layer me inputs aur neurons hain, toh ka shape hota hai (output rows, input columns), taaki ka answer -length vector aaye. Yeh ek badhiya sanity check hai — agar dimensions match nahi kar rahe, toh tumhara ulta hai. Batch me kaam karte time saare examples ko columns bana ke ek bade matrix multiply se process karte hain, jo GPU pe bahut fast chalta hai.
Yaad rakhne ka mantra: "Weigh, Bias, Bend — Repeat". Bas yahi cheez har layer me repeat hoti hai jab tak last layer se (prediction) nahi nikal aata. Yeh step baad me backpropagation ke liye foundation banta hai — kyunki gradients nikaalne ke liye humein forward pass ke aur values chahiye hoti hain.