Skip to content
AI360XpertBeta
Playgrounds

Neural Networks

Backpropagation

Multiply local Jacobians along each path; add contributions where a value feeds multiple paths.

Guided steps 1 / 7

Stage 1 of 7: The Forward Pass

ReLU. Forward: x₁ 1.20 and x₂ -1.00 give z₁ 1.46, h₁ 1.46, then z₃ 2.19 and prediction y 2.190 against target 0.50. Neither unit on this path is saturated.

Inspected h1; parameter w31=1.5, gradient 2.467400e+0. z=1.46, a=1.46, local slope=1, dL/da=2.535, delta=2.535. Layout is illustrative; raw values are in Under the hood.

  • Input value
  • Forward weight
  • Negative weight
  • Backward gradient
Adjust parameters

The first input. It is also the last factor in the chain for w₁₁.

The first-layer weight whose gradient this lab traces back to the loss.

Prediction (y)2.1900Prediction (y): 2.1900

Which products produce this output?

Follow both inputs into both hidden units, then the output. Select a node to connect its graph value with the raw inspector. The layout shows connectivity, not feature geometry.

Pre-activation

The sum of weighted incoming activations plus a bias, before applying f.

Check this stage

Check your understanding

Watch the chain rule assign blame to individual weights — as a product, factor by factor, not as an answer to take on trust.

Backpropagation computes how a scalar loss changes when an input or parameter changes. It multiplies local derivatives along each path and adds contributions when paths meet. An optimiser can use those gradients to change parameters; this lab performs no updates.

Follow one complete computation

The architecture is two real inputs, two hidden units and one scalar output. The same selected sigmoid, tanh or ReLU activation applies to both hidden units and the output. The target is a real number, including values outside a bounded activation’s range. There is no class encoding, classification threshold or calibrated probability interpretation.

Sigmoid is f(z)=1/(1+exp(−z)), with slope f(z)(1−f(z)). Tanh is f(z)=tanh(z), with slope 1−f(z)². ReLU is f(z)=max(0,z), with slope one for positive z and zero for negative z; this implementation chooses zero at the origin. These are the actual conventions used by both passes.

Start with the forward pass. Change Input x₁ or Weight w₁₁ and select a node in the graph with click, Enter or Space. The native Inspect node control selects the same quantity. Open Under the hood for both incoming products, bias, pre-activation and activation of every unit.

z1=x1w11+x2w12+b1,z2=x1w21+x2w22+b2z_1=x_1w_{11}+x_2w_{12}+b_1,\qquad z_2=x_1w_{21}+x_2w_{22}+b_2 h1=f(z1),h2=f(z2),z3=h1w31+h2w32+b3,y=f(z3)h_1=f(z_1),\quad h_2=f(z_2),\quad z_3=h_1w_{31}+h_2w_{32}+b_3,\quad y=f(z_3)

The opening ReLU experiment gives z₁=1.46, z₂=−1.1, h₁=1.46, h₂=0 and y=2.19. The target is 0.5. The scalar loss is half squared error for one observation, without batch reduction or regularisation:

L=12(y−t)2=1.42805,∂L∂y=y−t=1.69L=\frac12(y-t)^2=1.42805,\qquad \frac{\partial L}{\partial y}=y-t=1.69

These numbers change immediately when a mathematical control changes. Manual settings are the current parameters; there is no training initialisation, rate, epoch or hidden update schedule.

Multiply local Jacobians backwards

The output delta is a derivative with respect to a pre-activation, not an activation:

δ3=∂L∂z3=(y−t)f′(z3)\delta_3=\frac{\partial L}{\partial z_3}=(y-t)f'(z_3)

Returning through the affine output uses its weight Jacobian. It is not just an activation slope:

∂L∂h1=δ3w31,∂L∂h2=δ3w32,δi=∂L∂hif′(zi)\frac{\partial L}{\partial h_1}=\delta_3w_{31},\qquad \frac{\partial L}{\partial h_2}=\delta_3w_{32},\qquad \delta_i=\frac{\partial L}{\partial h_i}f'(z_i)

The parameter derivatives then multiply by the local source activation; a bias has local derivative one:

∂L∂w31=δ3h1,∂L∂b3=δ3,∂L∂w11=δ1x1,∂L∂b1=δ1\frac{\partial L}{\partial w_{31}}=\delta_3h_1,\quad \frac{\partial L}{\partial b_3}=\delta_3,\quad \frac{\partial L}{\partial w_{11}}=\delta_1x_1,\quad \frac{\partial L}{\partial b_1}=\delta_1

At the opening settings, δ₃=1.69, δ₁=2.535, ∂L/∂w₃₁=2.4674 and ∂L/∂w₁₁=3.042. Change x₁ to zero and compare the w₁₁ and b₁ derivatives: the weight receives zero input, but the bias can still affect the loss. Reveal the prediction card to read both current values.

On the final stage, select any of the nine weights and biases. Its graph edge or destination unit is emphasised, the graph labels its value and gradient, and the inspector expands its complete chain. Inspecting another node or parameter leaves the experiment unchanged.

Add contributions across paths

An input affects both hidden units, so both paths contribute:

∂L∂x1=δ1w11+δ2w21,∂L∂x2=δ1w12+δ2w22\frac{\partial L}{\partial x_1}=\delta_1w_{11}+\delta_2w_{21},\qquad \frac{\partial L}{\partial x_2}=\delta_1w_{12}+\delta_2w_{22}

The drawer retains each signed contribution and the sum. A zero total need not mean either path is zero. To see exact cancellation, use ReLU, x₁=1, x₂=0, w₁₁=w₂₁=1, w₁₂=w₂₂=0, b₁=b₂=0, w₃₁=1, w₃₂=−1, b₃=1 and target 0. Both hidden activations are 1 and y=1. The two contributions to x₁ are +1 and −1. Their sum is zero even though individual parameter gradients remain nonzero.

The matrix form uses the actual weight matrices shown in inspection: hidden deltas multiply the transposed output weights and local activation slopes, then input derivatives multiply the transposed first-layer weights. Summation is part of this Jacobian product.

Separate attenuation from a complete gradient

Load the saturated sigmoid preset or keep the original weights and increase x₁ after switching to sigmoid. The activation-only product is f′(z₃)f′(z₁). Two sigmoid slopes cannot exceed 0.25²=0.0625. On the original weights, increasing x₁ from 1.2 first takes this product below 0.01 at x₁=2.8 for sigmoid and 1.3 for tanh.

This product omits weight Jacobians, input and residual. It is not the full gradient, a proof of training failure or a bound on an arbitrary network’s full derivative. Weights can attenuate or amplify, and signed paths can cancel. Active ReLU slopes are one, while inactive slopes are zero; neither fact removes the weight Jacobians.

ReLU uses f′(z)=1 for z>0 and zero otherwise, including a chosen zero value at the nondifferentiable origin. A central finite difference at that kink does not prove this convention. A locally inactive unit can reactivate after an input, upstream value or parameter changes.

A small positive raw gradient is different from a rounded display zero. JavaScript floating-point sigmoid/tanh activations can also round to their endpoints, giving a computed zero slope even where the mathematical slope is positive. That is endpoint rounding, not evidence of gradual underflow. Nonfinite arithmetic withholds graph geometry and headline numbers while retaining raw inspection.

Read the picture and recover the experiment

Graph positions illustrate connectivity. They are not feature coordinates or a loss landscape. Edge widths encode weight magnitude with the primitive’s minimum width; the finite manual ranges bound their maximum. Labels round; the drawer retains raw double-precision values. There is no field sampling, projection, normalisation or clipped data plot.

Explore freely unlocks the complete graph and all mathematical controls. The saturation preset saves the preceding settings, stage, inspection, mode and prediction for Restore experiment, even after further edits. Reset controls keeps the guided stage, returns guided and clears that snapshot. Share reproduces the displayed guided stage, both inputs, target, all parameters, activation and inspection by recomputing a single pass. Guesses, progress, mode identity and recovery stay local. No data seed or playback is needed.

Gradients are not updates

No parameter update is applied here. Backpropagation computes gradients at the current parameters; an optimiser chooses a rule and rate for applying them. Continue to Gradient Descent for actual updates or Multi-Layer Perceptron for full-batch training. A single-row derivative does not establish generalisation or representational limits.

The computational conventions follow Deep Learning, chapter 6 and the Stanford CS231n chain-rule notes.

Stage recap

  1. The Forward Pass

    Follow both inputs into both hidden units, then the output. Select a node to connect its graph value with the raw inspector. The layout shows connectivity, not feature geometry.

  2. Error and Loss

    Compare the scalar output with a real target. Half squared error gives dL/dy=y−t, while dL/dt=t−y. The target is not a class encoding.

  3. Output Layer Blame (d3)

    delta3=dL/dz3=(y−t)f′(z3). The output gradient dL/dy is multiplied by the local activation slope. Backward arrows carry derivatives of the loss, not forward values.

  4. Output Weight Gradient

    dL/dw31=delta3 h1, while dL/db3=delta3. These are derivatives, not updates. The output weight Jacobian with respect to h is (w31,w32).

  5. Hidden Layer Blame (d1)

    dL/dh1=delta3 w31 and dL/dh2=delta3 w32. Multiply each by its own activation slope to obtain delta1 and delta2. Either path can be zero locally.

  6. Input Weight Gradient

    dL/dw11=delta1 x1 and dL/db1=delta1. At a reused input, add both paths: dL/dx1=delta1 w11+delta2 w21. Opposite contributions can cancel.

  7. Vanishing Gradients

    Inspect every parameter and both branches. The activation-only product is at most 0.0625 for two sigmoid slopes; the complete gradient also includes weight Jacobians. Small gradients, rounded zeros and inactive ReLUs are different observations.

Reference

Architecture
2 inputs → 2 hidden units → 1 scalar output. The selected activation applies to hidden and output units.
Loss and target
One real target; L=½(y−t)². No batch, classification, probability calibration or parameter updates.
Activation gradient
dL/dh1 = delta3 × w31; this includes the weight Jacobian.
Pre-activation gradient
delta1 = dL/dz1 = (dL/dh1) × f′(z1). ReLU uses slope zero at z=0 by convention.
Parameter gradients
dL/dw = delta × source activation; dL/db = delta.
Fan-out
dL/dx1 = delta1 × w11 + delta2 × w21. Contributions can cancel.
Activation-only product
f′(z3)f′(z1) excludes weight Jacobians, input and loss derivative. It is not a full network gradient.
No update here
Backpropagation computes derivatives; an optimiser applies updates elsewhere.

Break it on purpose

Sigmoid saturation makes the activation-slope product small. This is only part of the full gradient, which also includes weights, input and residual. Inactive ReLUs can instead give exact local zeros.