Chapter 6 · Section 6.2

Multi-Layer Networks & Forward Propagation

One neuron is a calculator. Stack many in layers, and you get a network that can model almost anything - from beam deflection to traffic flow. Let's watch the signal flow.

16 min read Architecture Forward Pass Matrix Math

From One Neuron to a Network

The Limitation of a Single Perceptron

In Section 6.1 we built a single perceptron - a small machine that draws one straight line through the data. That's enough to decide "tension or compression?", but the world rarely cooperates with a single line. Real engineering relationships - soil settlement, traffic congestion, concrete creep - are non-linear and multi-modal.

The fix is brilliantly simple: stack neurons in layers, and feed the output of one layer as the input to the next. The result is the Multi-Layer Perceptron (MLP) - the workhorse of modern deep learning.

Anatomy of an MLP

Every MLP has three kinds of layers:

  • Input layer - one neuron per feature. No computation; just holds the raw inputs (e.g. beam length, load, modulus).
  • Hidden layer(s) - the "brain". Each neuron takes a weighted sum of all previous-layer outputs and applies a non-linear activation. You can have one or many.
  • Output layer - produces the final prediction. One neuron for regression (e.g. predicted deflection in mm), several for classification (e.g. failure mode probabilities).

CE Analogy — The Neural Network as a Truss

Picture a steel truss. Load (signal) enters at the supports (input layer), propagates through interconnected members (hidden layers), and exits as reactions and forces at the far end (output layer). Each joint redistributes the load according to the stiffness of its members — exactly like how each neuron redistributes signal according to its weights.

A taller, deeper truss can carry more complex load patterns. Likewise, a deeper network can capture more complex input-output relationships.

Naming convention: a network described as 3–4–3–2 has 3 input neurons, two hidden layers (4 then 3 neurons), and 2 output neurons. We will use this notation throughout the chapter.

Why Depth Matters

Each Layer Learns a Higher Abstraction

The magic of deep networks is that each successive layer learns increasingly abstract features built from the previous layer's outputs.

Consider a network predicting whether a building plan is structurally sound:

  • Layer 1 might detect basic patterns: "is the span very long?", "is the load very high?"
  • Layer 2 combines those: "long span + heavy load" → "high bending moment risk"
  • Layer 3 combines further: "high bending risk + low steel ratio" → "likely failure mode"
  • Output: probability of safe / unsafe

You never tell the network this hierarchy — it discovers it on its own during training. That's the breakthrough.

Width vs Depth

For a fixed parameter budget, you can spend it two ways:

Wide & Shallow

Few layers, many neurons each (e.g. 10–200–1).

  • Easier to train (fewer vanishing-gradient issues)
  • Memorises well, generalises less
  • Captures broad patterns but not deep hierarchies

Narrow & Deep

Many layers, fewer neurons each (e.g. 10–16–16–16–16–1).

  • Captures hierarchical features beautifully
  • Harder to train (needs careful initialisation)
  • State-of-the-art for images, language, structural patterns

Modern practice (post-2015) overwhelmingly favours deep architectures, with techniques like residual connections and batch normalisation to keep training stable.

Engineer's rule of thumb: start with 2–3 hidden layers and widths between 16 and 128. Most civil-engineering tabular problems don't need ResNet-50.

Forward Propagation, Step by Step

The Signal Flows Left to Right

Forward propagation (the "forward pass") is the process of pushing an input through the network to get a prediction. It happens in three steps per layer:

  1. Weighted sum — each neuron multiplies every incoming activation by its weight and adds them up.
  2. Add bias — a per-neuron offset, like the intercept in a linear regression.
  3. Apply activation — pass through a non-linear function (ReLU, sigmoid, tanh — see 6.3).

The output of one layer becomes the input of the next, until we reach the final output. No randomness, no learning — just deterministic arithmetic.

Matrix Notation

Writing it out neuron-by-neuron is exhausting. Linear algebra makes it elegant:

a(L) = σ( W(L) · a(L-1) + b(L) )

Where:

  • a(L) — the vector of activations at layer L
  • W(L) — the weight matrix connecting layer L−1 to L. Its shape is (neurons in L) × (neurons in L−1)
  • b(L) — the bias vector for layer L
  • σ — the activation function (applied element-wise)

To run the entire forward pass, you simply repeat this equation for each layer. That's it. The whole network — potentially billions of parameters — is just a chain of matrix multiplications interleaved with non-linearities.

Why Matrices? Parallelism.

Computing 128 weighted sums one-at-a-time in a Python loop is slow. Computing them as a single matrix-vector product is massively parallel on a GPU — thousands of multiplications happen in the same clock cycle.

This is why frameworks like PyTorch and TensorFlow store everything as tensors: the math is identical to what we wrote above, but the hardware executes it at terabytes-per-second.

NumPy A 3-layer forward pass in 4 lines
def forward(x, weights, biases, activation):
    a = x
    for W, b in zip(weights, biases):
        a = activation(W @ a + b)
    return a

CE Analogy — Hydraulic Network

Forward propagation is like water flowing through a pipe network. At each junction (neuron), the inflows are summed (weighted by pipe diameter), a small head loss (bias) is added, and a valve (activation) decides how much flows onward. The final reservoir level is the network's prediction.

Demo 1 — Forward Propagation Visualizer

Watch a signal travel through a 3–4–3–2 network. Click Inject Signal to release activations from the input layer and see them light up neurons sequentially. Hover over any neuron to inspect its weighted sum and final activation. The right panel shows the matrix multiplication unfolding.

3–4–3–2 Network

Demo 2 — Network Architecture Builder

Drag the sliders to add hidden layers and change neuron counts. The canvas redraws instantly. Watch how the parameter count (weights + biases) explodes as you go wider or deeper — this is why training cost grows so fast.

Build Your MLP

Total weights
0
Total biases
0
Total parameters
0
Architecture
—

The Universal Approximation Theorem

The Big Promise

In 1989, Cybenko (and later Hornik) proved an astonishing result, informally:

A feed-forward network with a single hidden layer of sufficient width and a non-linear activation function can approximate any continuous function on a closed interval to arbitrary precision.

In other words: there is no continuous engineering relationship — beam deflection, soil consolidation curves, traffic flow — that an MLP cannot, in principle, represent.

The Fine Print

The theorem says "can", not "will easily". In practice:

  • "Sufficient width" can mean enormously wide. Often impractical.
  • The theorem says nothing about how to find the right weights.
  • Going deep instead of wide tends to be exponentially more efficient.
  • Generalisation (performing well on unseen data) is a separate, harder problem.

Still, the theorem is the philosophical foundation: it tells us the architecture is not the bottleneck — training is.

CE Analogy — Universal Cross-Section

It's like saying: "Given enough steel, you can build a beam to span any distance." True — but the cost, deflection, and constructability eventually become absurd. Engineering is about finding the elegant solution, not the theoretically possible one. Same with neural networks.

CE Application — Predicting Beam Deflection

The Problem

You want to predict the maximum deflection δ of a simply supported beam given:

  • span L (m)
  • uniform load w (kN/m)
  • moment of inertia I (m4)
  • Young's modulus E (GPa)

For a simple case, you'd use δ = 5wL4 / (384EI). But for tapered sections, partial loads, end restraints, and composite materials — closed-form solutions vanish quickly. Enter the MLP.

The Architecture

A reasonable starting design:

  • Input layer (4 neurons): L, w, I, E (normalised)
  • Hidden layer 1 (16 neurons, ReLU): learns combinations like wL, wL4, EI
  • Hidden layer 2 (8 neurons, ReLU): learns ratios like wL4/(EI)
  • Output layer (1 neuron, linear): predicted δ in mm

Train it on a synthetic dataset of 10 000 finite-element simulations. After training, you have a millisecond surrogate model for what would otherwise be a multi-second FEA call — perfect for design optimisation loops.

PyTorch Defining the beam-deflection MLP
import torch.nn as nn

class BeamDeflectionMLP(nn.Module):
    def __init__(self):
        super().__init__()
        self.net = nn.Sequential(
            nn.Linear(4, 16),  nn.ReLU(),
            nn.Linear(16, 8),  nn.ReLU(),
            nn.Linear(8,  1),
        )

    def forward(self, x):
        return self.net(x)   # one matrix multiply per layer
Reality check: always benchmark the MLP against the closed-form solution where one exists. If it can't reproduce the textbook answer to within a few percent, your data, normalisation, or architecture is wrong.

Civil Engineering Application

Concrete Strength Prediction

An MLP with inputs [cement, water, fly ash, coarse aggregate, fine aggregate, superplasticizer, age] can predict 28-day f'c within ±3 MPa. Each hidden layer captures interactions the individual inputs can't — like how w/c ratio and fly ash percentage combine nonlinearly.

Sensor Fusion for SHM

Bridge structural health monitoring systems fuse data from accelerometers, strain gauges, and temperature sensors. The forward pass through an MLP combines these heterogeneous signals into a single damage index — something no single sensor type can provide alone.

Check Your Understanding

Q1. In the equation a(L) = σ(W(L) a(L-1) + b(L)), what is W(L)?

  • The activation function applied to layer L.
  • A matrix of weights connecting layer L−1 to layer L.
  • A scalar bias for the output layer only.
  • The training loss for layer L.

Q2. Why do we use matrix notation in forward propagation?

  • It makes the math harder so researchers feel important.
  • It is the only way activations can be computed.
  • It allows all neurons in a layer to be computed in parallel on GPUs.
  • It eliminates the need for biases.

Q3. The Universal Approximation Theorem says, informally:

  • Any neural network can be trained in finite time.
  • A wide-enough MLP with non-linear activation can approximate any continuous function.
  • Deep networks always outperform shallow networks.
  • Linear networks can solve any classification problem.

Q4. What primarily distinguishes deep narrow networks from wide shallow ones?

  • Deep networks always have more parameters.
  • Wide networks cannot have biases.
  • Deep networks must use sigmoid activation.
  • Deep networks build hierarchical features layer by layer; wide ones spread capacity in one layer.
Try it interactively

Add hidden layers and watch the decision boundary bend

Slide hidden units and hidden layers on a moons / circles / XOR / spiral dataset and see exactly when an MLP gains the capacity to separate them.

Open Lab
Mini case study

Forward propagation in practice: Naderpour’s FRP-confined column MLP

FRP wrapping is the dominant retrofit for under-strength reinforced-concrete columns in seismic regions, but ACI 440.2R’s closed-form confinement model under-predicts strength on high-strength concrete. In 2010 Naderpour, Kheyroddin and Amiri trained a multi-layer perceptron on 213 axial-compression tests; ten years and 1500+ citations later, the same forward-prop architecture is the open benchmark every FRP study compares against.

0Lab columns in training set
0Input features
0R² on hold-out
0Citations to date

ACI 440.2R-08 estimates confined concrete strength fcc from a single lateral-confinement ratio. On high-strength columns (fc' > 50 MPa) and aramid wraps the formula systematically under-predicts by 15–25%. Designers need a better surrogate that respects the six measured drivers: column diameter, height, fc', FRP thickness, FRP tensile strength, FRP modulus.

“The closed form is conservative everywhere — and uneconomic by 20% on high-strength concrete.”

  • 6 → 8 → 1 forward network — one hidden layer of 8 tanh neurons; trained by Levenberg-Marquardt backprop on 70/15/15 split.
  • Each forward pass = matrix-multiply (6×8) → tanh → matrix-multiply (8×1) — the canonical 2-layer feed-forward.
  • Standardised inputs with z-score normalisation; output un-scaled at inference for a strength in MPa.
Confined-strength prediction R² on the held-out FRP column test set

The 2-layer MLP closes nearly the entire gap to the deep network — on a 213-row dataset, depth doesn’t help much past 8 hidden neurons.

  • R² = 0.96 on hold-out vs 0.71 for ACI 440.2R-08.
  • 15–25% material saving on high-strength columns when the MLP replaces the closed form in retrofit design.
  • Open-source weights made it the default benchmark for every subsequent FRP-confinement paper.
  • One hidden layer is often enough. Universal-approximation theorem in action — deeper hurts on small CE datasets.
  • Forward prop is just matrix math. 6×8 then 8×1 — cheap enough to run on a contractor’s spreadsheet.
  • Surrogate models beat conservative codes economically — but only when validated against the same lab database the code committee used.