From Neurons to Networks
The forward pass
Stacking neurons into layers of computation
Stack neurons into layers, wire them up, and push numbers through - the whole of what a network does is one river of arithmetic flowing input to output.
A single neuron takes a weighted sum of its inputs, adds a bias, and squashes the result. That's it. A neural network is just a lot of those neurons arranged in layers, with the output of one layer piped into the next. Feeding a number in at the left and reading the answer out at the right - layer by layer, no learning, no going backwards - is called the forward pass. Master this one motion and you understand exactly what every network on Earth is doing when it makes a prediction.
The picture to hold in your head
From one neuron to a layer
A layer of neurons all look at the same inputs but with different weights, so each one detects something different. Line up their weight rows and you get a matrix ; line up their biases and you get a vector . Then the entire layer - every neuron at once - is a single expression:
One layer, in matrix form (this is Lesson 13 in disguise)
is precisely the matrix-vector product from the linear-algebra lesson: row of dotted with gives neuron 's weighted sum. Add the bias vector, then apply the activation to every entry. In our demo below the hidden layer's is and is , so is - three weighted sums, one per hidden neuron.
Trace a forward pass, one layer at a time
Here is a tiny network: 2 inputs to 3 hidden to 1 output, with fixed weights (teal wires excite, red wires inhibit; thicker means a bigger weight). Set the two inputs, then press Forward - or step through by hand. Activations light up and flow left to right, each neuron filling in with the strength of its firing. Hover any wire to read its weight; hover any neuron to see its exact weighted-sum-then-squash.
Inputs ready. The network receives x = [x₁, x₂] - the two numbers you set. Nothing has fired yet.
The aha: each layer bends the space
Depth, width, and why the squash is not optional
Width is how many neurons sit in a layer - how many different features it can detect at once. Depth is how many layers you stack - how many times the data gets re-transformed on its way through. More width gives a layer more room; more depth lets later layers build features out of earlier features. But all of that power hinges on one small piece: the activation function .
Remove σ and the whole network collapses
import numpy as np
def sigmoid(z):
return 1 / (1 + np.exp(-z))
# one layer: a = sigma(W @ x + b)
def layer(x, W, b):
return sigmoid(W @ x + b)
W1 = np.array([[ 0.8, -0.5],
[-0.6, 0.9],
[ 0.4, 0.7]]) # hidden weights, 3x2
b1 = np.array([0.1, -0.2, 0.0])
W2 = np.array([[1.2, -0.8, 0.5]]) # output weights, 1x3
b2 = np.array([-0.3])
x = np.array([0.60, 0.20]) # the inputs you set
h = layer(x, W1, b1) # hidden activations, shape (3,)
y = layer(h, W2, b2) # prediction, shape (1,) -> ~0.60That is the whole forward pass: multiply, add bias, squash - then hand the result to the next layer call. A deep network is nothing but this loop run a few dozen more times.
Check yourself
In matrix form, one layer of a network computes exactly:
Strip every activation σ out of a deep network. What can it then represent?
Recall: write one layer's forward pass in matrix form, and name each piece.
Try to state it, then check.
Lock it in
- One layer is a single expression: - matrix multiply, add bias, squash.
- A forward pass is just that motion repeated, each layer's output feeding the next, input flowing left to right.
- Width is neurons per layer; depth is how many layers, letting later layers build features out of earlier ones.
- Without the non-linear σ, stacked layers collapse into one linear map, so σ is the only reason depth buys anything.
Primary source
Ask your teacher