The same three-layer hierarchical predictive-coding network as the 3D version, redrawn flat so the belief updates are legible node-by-node instead of behind a rotating camera. Each layer i tries to predict the layer below it with weights W, producing a prediction error ε that drives inference:
pred₀ = W₁ · tanh(x₁) ε₀ = d(t) − pred₀ (sensory layer)
pred₁ = W₂ · tanh(x₂) ε₁ = x₁ − pred₁ (hidden layer)
F = ½ ( π₀‖ε₀‖² + π₁‖ε₁‖² ) (variational free energy)
Belief states x₁ and x₂ perform gradient descent on F — exactly the update Karl Friston's free-energy principle and Rao & Ballard's 1999 predictive-coding model of cortex prescribe:
ẋ₁ = π₀ W₁ᵀ · [ε₀ ⊙ (1−tanh²x₁)] − π₁ε₁ − λx₁
ẋ₂ = π₁ W₂ᵀ · [ε₁ ⊙ (1−tanh²x₂)] − λx₂
- Sensory precision π₀ — how much the top layers trust incoming data versus their own prior; raising it makes beliefs snap to the signal faster (mimics attention).
- Prior precision π₁ — how strongly the hidden layer trusts its own top-down prediction from the belief layer above.
- Inference rate — the step size of the gradient-descent update (how fast beliefs are revised).
- Inject surprise — jumps the sensory signal to an unpredicted value; watch ε₀ and F spike on the chart, then fall back as the network re-infers new beliefs that explain the surprising input away.
Verified: this update rule was checked against the stated free-energy functional by taking its analytic gradient (∂F/∂x₁, ∂F/∂x₂) directly — the sign and structure of every term above matches, and a standalone run confirms the network reaches a steady tracking error rather than drifting or diverging, exactly as a gradient-descent estimator chasing a moving (non-stationary, sinusoidal) sensory target should. Node colour encodes each unit's local prediction error; the small paired bars under each sensory node show the raw signal against what the network currently predicts for it — the gap between them is ε₀.