5.6.6 · D2Machine Learning (Aerospace Applications)

Visual walkthrough — Neural network fundamentals — neuron, activation functions (ReLU, sigmoid, tanh)

3,097 words14 min readBack to topic

Everything below starts from a child who has seen multiplication and addition and nothing else. Every symbol is earned before it is used.


Step 1 — One input, one weight, one bias: the straight line

WHAT. The smallest possible neuron takes one number in — call it — and produces one number out. Before any fancy function, the neuron does just two things: it scales by a number , then shifts the result by a number . We name this scaled-and-shifted number :

  • — the input number (say, an airspeed reading).
  • — the weight: it stretches or squashes . Big = steep line, matters a lot.
  • — the bias: it lifts the whole line up or down without touching its steepness. This is exactly what makes the map affine rather than strictly linear.
  • — the weighted sum, the neuron's raw score before any bending.

WHY these two operations and no others? Scaling () is the only way to say "this input is 3× more important." Shifting () is the only way to let the neuron output something non-zero when . Together they are the most general straight line you can write — a line that need not pass through the origin, i.e. an affine line. That is exactly the point — and also exactly the limitation we will hit.

PICTURE. The graph of is a ruler-straight line. is its tilt; is the height where it crosses the vertical axis.

Figure — Neural network fundamentals — neuron, activation functions (ReLU, sigmoid, tanh)

Step 2 — Many inputs: the line becomes a weighted sum

WHAT. Real neurons watch many numbers at once: airspeed, altitude, angle-of-attack. Call them . Each gets its own weight . The neuron multiplies each pair and adds them all, then adds one shared bias:

The tidy shorthand for "add up all the " is the sum symbol (a capital Greek "S", for Sum):

  • — "let run from to and add every term." Nothing mysterious: it is just a compact for loop that means .
  • Everything else is exactly Step 1, repeated once per input.

WHY still just addition and scaling? Because we have not yet added anything else. Even with a thousand inputs, is still a flat (affine) plane in disguise — the multi-input twin of the straight line. Hold that thought; it is about to bite us.

PICTURE. With two inputs the "line" becomes a tilted flat sheet floating over the floor. Its height at any point is .

Figure — Neural network fundamentals — neuron, activation functions (ReLU, sigmoid, tanh)

Step 3 — Stack two neurons and watch the line refuse to bend

WHAT. Deep learning's promise is stacking: feed one layer's output into another. First we must upgrade our shorthand from single numbers (scalars) to lists of numbers (vectors) and grids of numbers (matrices), because a real layer has many neurons.

With that vocabulary, layer 1 turns the input vector into the hidden vector , and layer 2 turns into :

Substitute the first into the second:

Here is matrix times matrix ( times gives a grid) — one combined weight box — and is one combined bias number.

WHY does this matter? Look at the final line: it has the exact shape a single affine map again. Two layers collapsed into one. Multiplying two affine functions and adding shifts can never escape straightness. Stack a hundred; still one straight (affine) map.

PICTURE. Two straight ramps chained together produce one straight ramp — the fold you hoped for never appears.

Figure — Neural network fundamentals — neuron, activation functions (ReLU, sigmoid, tanh)

Step 4 — The problem a straight line cannot solve: XOR

WHAT. Here is a task that needs a curve. Four points on a floor:

wanted label
0 0 0 (blue)
0 1 1 (orange)
1 0 1 (orange)
1 1 0 (blue)

This is XOR: output 1 when the inputs disagree. We want to draw a boundary that keeps the two orange points on one side and the two blue points on the other.

WHY it is impossible with Step 3's machine. The blue points sit at opposite corners; so do the orange. No single straight line can separate two diagonal pairs — try it and one point is always on the wrong side. Since stacked affine layers = one straight boundary (Step 3), the whole affine network cannot learn XOR.

PICTURE. Every straight cut you attempt leaves one point stranded.

Figure — Neural network fundamentals — neuron, activation functions (ReLU, sigmoid, tanh)

Step 5 — Insert one bend: the activation function

WHAT. Between the two layers we slip in a function that is not a straight line — an activation function. Now:

The simplest possible bend is ReLU (Rectified Linear Unit) — "let positives through, flatten negatives to zero":

  • For : output equals input — a ramp.
  • For : output is flat zero — the "door is shut."
  • The corner at is the crucial thing: it is a kink, the very non-straightness Step 3 lacked.

WHY does a single kink rescue us? A concrete 1-D check. Take two affine pieces of the same input : and . Adding them, — still one straight line, no escape. But push each through ReLU first and then add:

Try numbers and , i.e. . That is the absolute-value "V" — provably not of the form , because its slope is on the left and on the right. The refuses to distribute across the sum: in general (at : on the left, but -style bookkeeping gives ). One bend has bought us a genuine corner — the collapse of Step 3 is broken.

PICTURE. ReLU: flat on the left, a rising ramp on the right, with a sharp elbow at the origin.

Figure — Neural network fundamentals — neuron, activation functions (ReLU, sigmoid, tanh)

Step 6 — Watch the bends fold space and solve XOR

WHAT. Give the tiny network two hidden ReLU neurons. Each ReLU contributes one fold. Combining two folds, the network builds a boundary shaped like a bent line — a "V" or a corner — instead of a straight cut.

WHY this works where Step 4 failed. A corner can hug the two blue points into one region and push the two orange points outside it. The impossible straight-line separation becomes an easy folded-region separation. This is the payoff of Step 5's kink, made visible.

PICTURE. The learned boundary bends around the blue diagonal; orange and blue now sit cleanly apart.

Figure — Neural network fundamentals — neuron, activation functions (ReLU, sigmoid, tanh)
  • Blue region ← both points labelled 0.
  • Orange region ← both points labelled 1.
  • The boundary is piecewise-straight (made of ReLU segments) but globally curved — exactly what one affine layer could never produce.

Step 7 — Not every bend is equal: three activations side by side

WHAT. ReLU is one bend; there are smoother ones. All three from the parent note, on one axis:

Reading each symbol where it sits:

  • — the number raised to ; it shrinks fast as grows, so climbs toward .
  • sigmoid, squashes any input into the open interval : a confidence meter.
  • — same S-shape but squashed into , so it is zero-centred (negatives allowed).

WHY care about which one? Their steepness differs, and steepness is what gradient descent rides on:

  • ReLU's slope is exactly for — learning signals pass undiminished.
  • Sigmoid's slope never exceeds (its steepest point, at ); tanh's never exceeds but both flatten to nearly at the extremes ("saturation").

PICTURE. ReLU's hard elbow, sigmoid's gentle S with its max-slope tangent marked, tanh's symmetric S with its slope- tangent and its asymptotes — all overlaid.

Figure — Neural network fundamentals — neuron, activation functions (ReLU, sigmoid, tanh)

Step 8 — The degenerate case: a flat activation is no activation

WHAT. What if someone "simplifies" and picks a linear activation, ? Then

— we are right back at Step 3's collapse. Likewise a constant activation kills all input dependence entirely ( ignores ).

WHY show this. It nails the boundary of the whole idea: the bend must be genuinely non-linear and input-dependent. A straight or flat silently undoes everything. This is also why a ReLU neuron whose is negative for all data is dead — it is locally the flat, useless case, and (see the parent's Dead-ReLU note) its gradient is so it never recovers.

PICTURE. Two "bad bends": the identity line (collapses to affine) and a flat constant (ignores input) — neither can fold space.

Figure — Neural network fundamentals — neuron, activation functions (ReLU, sigmoid, tanh)

The one-picture summary

Figure — Neural network fundamentals — neuron, activation functions (ReLU, sigmoid, tanh)

Read the four panels left-to-right, top-to-bottom — they replay the whole page:

  1. Top-left "linear = straight": one affine layer is a ruler line (Steps 1–3). Stacking more never bends it.
  2. Top-right "line fails XOR": the four XOR dots; the red dashed line is any straight cut, and it always strands a point (Step 4).
  3. Bottom-left "add a bend (ReLU)": insert — the green ramp with the red kink at the origin is the new non-linear ingredient (Step 5).
  4. Bottom-right "folds solve XOR": two ReLU folds carve a corner-shaped boundary that finally separates blue from orange (Step 6).

The through-line: stretch (weights) → slide (bias, affine) → BEND (activation). Only the bend escapes the straight-boundary trap.

Recall Feynman retelling — say it back in plain words

Start with a machine that only knows two tricks: stretch a number and slide it. Stretch-and-slide is what grown-ups call an affine map — a straight ruler line that need not pass through zero. Chain a hundred of these machines and — surprise — you still only get one straight line, because stretching a stretch is just a bigger stretch and sliding a slide is just a bigger slide. Now here's a puzzle four dots make, called XOR: two dots want "yes," two want "no," and they sit on opposite corners. Try to separate them with a ruler — you can't, ever; someone is always on the wrong side. So we add one new trick: after stretching, we bend the number — the simplest bend just flattens all the negatives to zero (that's ReLU, a door that shuts below zero). That single kink means the chained machines are no longer one straight ruler; they can fold the paper. (Proof you can feel: is the V-shape — no ruler makes a V.) Two folds make a corner, and a corner can finally wrap around the two "no" dots and leave the two "yes" dots outside. That's the whole secret of neural networks: stretch, slide, and — crucially — bend. Pick a bend that's actually curved (ReLU, sigmoid, tanh); pick a flat or straight one and you've thrown the magic away. And that one sharp point at the bottom of ReLU has no proper slope, so the computer just picks any value between and there and carries on.

Recall Quick self-test

Why can't stacked affine layers learn XOR? ::: Because stacking affine layers collapses to a single affine layer (), which can only draw one straight boundary — and no straight line separates XOR's diagonal pairs. What does the kink in ReLU buy you? ::: A genuine non-linearity: cannot be rewritten as a straight line (e.g. ), so layers stop collapsing and the network can fold its input space into curved boundaries. What is the difference between a linear and an affine map? ::: Linear is pure scaling (through the origin); affine adds a shift, . A "linear layer" is really affine whenever . What happens at for ReLU? ::: It is non-differentiable (left slope , right slope ); software uses a subgradient — any value in , usually . Which activation is zero-centred, and why is that nice? ::: , range ; being symmetric about zero lets it output signed values and generally helps gradient descent converge.

Where this leads: the steepness of each bend controls how learning signals flow backward — the subject of Backpropagation and Gradient Descent and its failure mode, Vanishing and Exploding Gradients. Choosing the bend and the starting weights together is Weight Initialization Strategies.