Why the true gradient is useless: the loss is a staircase

loss (count − target)²direction the surrogate gradient points

One LIF neuron (β = 0.9, θ = 1) receives a constant input of 1 through weight w for 20 steps. Its output is a spike count, so the loss can only change when w crosses a value where one more spike appears.

Watch a surrogate gradient train a neuron
target

1. Loss vs. weight: two learners, same start

true gradient (always 0)surrogate gradient

2. The neuron at the surrogate learner's weight

membrane U[t]spikethreshold θ

3. Where the gradient comes from: one dot per time step

One LIF neuron (β = 0.9, θ = 1), constant input 1 through weight w, 20 steps, loss = (spike count − target)². Each frame is one gradient-descent step on w (step size capped at 0.02 so the descent is visible). Surrogate: arctan, ∂S/∂U ≈ 1 / (1 + (π(U − θ))²); the reset is detached.

Backpropagation through time, step by step: three updates with real numbers

The same three updates on the loss landscape

One LIF neuron, starting weight w = 0.7, β = 0.9, θ = 1, input spikes x = (1, 0, 1, 1, 0, 1). Loss L = (spike count − 3)². Surrogate σ′(U − θ) = 1 / (1 + (π(U − θ))²); the reset is detached, so the backward pass follows only the membrane chain. Learning rate η = 0.005, three updates w ← w − η·∂L/∂w.

Surrogate gradients: same spike forward, smooth slope backward
Shape

Forward pass (what the network computes)

Backward pass (the slope used for learning)

true spike function / its derivativesmooth stand-in / surrogate derivative

How far back in time does the gradient reach?

Through the membrane alone, ∂U[t] / ∂U[t−1] = β, so an input n steps before the loss reaches it scaled by βⁿ (ignoring the surrogate factors of intermediate spikes and other paths).