41. What Is a Neural Network (Simple Explanation)
41.3 Forward Pass in Plain Words
Why. You should see the flow: X → weights → activation → next layer → ŷ.
What. For a tiny 2→2→1 network, each connection has a weight. Forward pass = compute outputs from inputs. Learning changes weights later via loss + gradients.
How.
Trace one forward pass in words
- Feed two numbers (e.g. scaled litres, distance).
- Hidden layer makes two new numbers.
- Output layer makes one score (then maybe a probability).
- Compare to the true label — that error drives learning (Chapters 42–43).
def relu(z):
return max(0.0, z)
# Fixed toy weights — intuition only
h1 = relu(0.5*1.2 + 0.2*0.3 + 0.1)
h2 = relu(-0.3*1.2 + 0.7*0.3 + 0.0)
y_hat = 0.6*h1 + -0.2*h2 + 0.05
print("hidden:", h1, h2, "output:", round(y_hat, 3))
Fictional numbers
Weights here are made up so you can see the arithmetic. Real nets learn them from data.