No history yet

Network Dynamics and Flow

From Neuron to Network

You already know that neural networks are composed of layers, which are themselves collections of individual neurons. But how does information actually move through this structure? The process is a highly organized, one-way street called the forward pass or forward propagation.

Think of it like an assembly line. Raw data enters at one end, and at each station (layer), it gets transformed. The output of one station becomes the input for the next, until a final, processed output emerges at the end. This entire journey from input to output is the forward pass. It's the network's way of making a prediction based on what it currently knows.

Lesson image

The Math of the Message

To process data efficiently, we don't calculate one neuron at a time. Instead, we use the language of linear algebra: vectors and matrices. The input data is a vector, and all the connection weights for a layer are organized into a single matrix. This allows us to compute the transformations for an entire layer in one go.

Each layer performs two main operations. First, it applies a linear transformation to its input. We take the input vector (xx), multiply it by the layer's weight matrix (WW), and add a bias vector (bb). This gives us an intermediate result, often called the pre-activation state or "logits," which we'll label zz.

z=Wx+bz = Wx + b

This equation is the workhorse of the network. It takes the input data, which exists as a point in a high-dimensional space, and rotates, stretches, and shifts it to a new position. The weight matrix WW handles the rotation and stretching, while the bias vector bb handles the shift.

The second operation introduces the crucial non-linearity. The pre-activation vector zz is passed through an activation function (represented by σ\sigma, the Greek letter sigma) to produce the layer's final output, the post-activation state, aa. This step is what allows the network to learn complex patterns that a purely linear model could not.

a=σ(z)a = \sigma(z)

Chaining Layers Together

The real power of deep learning comes from stacking these layers. The post-activation output vector aa from one layer becomes the input vector xx for the very next layer. This creates a chain of transformations, where the data is progressively refined as it flows through the network.

For this chain to work, the dimensions of the vectors and matrices must align perfectly. The number of columns in a layer's weight matrix must equal the number of neurons in the previous layer (the size of its input vector). The number of rows must equal the number of neurons in the current layer (the size of its output vector).

If Layer 1 has 784 neurons and Layer 2 has 128 neurons, the weight matrix connecting them, W2W_2, must have the dimensions 128x784.

LayerNumber of NeuronsInput Vector SizeWeight Matrix DimensionsOutput Vector Size
Input (Layer 0)784N/AN/A784
Hidden 1128784128 x 784128
Hidden 26412864 x 12864
Output (Layer 3)106410 x 6410

This sequence of nested operations means we can think of the entire network as one large, composite function. If f1f_1, f2f_2, and f3f_3 represent the operations of each layer, the network's final output is f3(f2(f1(x)))f_3(f_2(f_1(x))). Understanding the network in this way is the key that unlocks how we can train it using calculus, which we'll explore next.