AN INTERACTIVE GUIDE TO SPIKING NEURAL NETWORKSVOL. 01 / 2026.09

脉冲如何
学会计算?

从一只漏电电容,到跨越离散事件的梯度。
用五个可以动手的实验,串起脉冲神经网络的
动力学、时间反传与突触学习。

LIFUltraLIFBPTTSTDPEventProp
从一张地图开始

五个交互实验 · 可展开的数学推导 · 单文件离线阅读

THE ANATOMY OF A SPIKE01 → 05
输入膜电位脉冲 INPUTSTATEEVENT θ 0t₁t₂t LEARNING SIGNAL
连续的状态,离散的事件结构示意 / 非定量轨迹
02神经元动力学模型LIF · UltraLIF
02梯度计算方法BPTT · EventProp
01局部突触学习规则STDP
01THE MAP BEFORE THE MATH先看全貌,再看数学

They answer different questions.它们回答的,不是同一个问题。

How a neuron produces spikes and how a network learns a task are different questions. Separate the model, the gradient, and the learning rule before combining their equations.神经元“怎样产生脉冲”,与网络“怎样学会任务”,是两个层次。先把模型、梯度与学习规则分开,后面的公式才不会混在一起。

DYNAMICS

How does the state evolve?状态怎样演化?

LIF / UltraLIF

Define integration, output, and reset: these determine the network’s forward computation.[1][2]定义积分、输出和复位;决定网络前向计算什么。[1][2]

DIFFERENTIATION

How does error propagate backward?误差怎样回传?

BPTT / EventProp

Compute how parameters affect the loss along a discrete-time graph or a continuous event trajectory.[3][5]沿离散时间图或连续事件轨迹,计算参数对损失的影响。[3][5]

PLASTICITY

How does a synapse change?突触怎样更新?

STDP

Define a local weight update from the relative timing of pre- and postsynaptic spikes.[4]用突触前、后脉冲的相对时序,定义局部权重变化。[4]

UltraLIF can therefore be trained with BPTT. Standard LIF can use surrogate-gradient BPTT, STDP, or continuous-time event differentiation with EventProp. These are not five mutually exclusive algorithms.因此,UltraLIF 可以用 BPTT 训练;标准 LIF 可以搭配代理梯度 BPTT、STDP,或采用 EventProp 的连续时间事件求导。它们不是五个互相替代的算法。

从神经元 j 到神经元 i 的权重
积分后、复位前的膜电位
复位后的膜电位
该步输出:硬脉冲或软脉冲
膜时间常数,有时间量纲
离散漏电系数,无量纲
阅读约定以下先讲直觉和关键结论,再展开中间步骤。LIF 与 EventProp 的时间单位使用毫秒;示例电压与输入做归一化。UltraLIF 专指 2026 年 2 月 10 日的预印本 v1,本文采用其定义 4.1 的时序,并单独核对其极限与梯度主张。[2]
02NEURON DYNAMICS / THE CLASSIC MODEL神经元动力学 / 经典模型

LIF: a leaky capacitor that fires.LIF:一只会“放电”的漏电电容。

Input current raises the membrane potential; leakage pulls it toward rest. At threshold, the neuron emits a spike and resets: the three operations in Leaky Integrate-and-Fire.[1]输入电流把膜电位往上推,漏电把它拉回静息状态。达到阈值时,神经元发出脉冲,然后复位。这就是 Leaky Integrate-and-Fire 的三个动作。[1]

漏电 LEAK旧状态逐渐衰减
积分 INTEGRATE累积当前输入
放电 FIRE越过阈值,输出事件
复位 RESET进入下一轮演化

Start with current conservation从电流守恒开始

Let membrane capacitance be , leak resistance , and resting potential . The input splits into capacitive and leak currents:膜电容为 ,漏电阻为 ,静息电位为 。输入电流分为电容电流与漏电流:

2.1

Define , then set and to obtain the normalized subthreshold equation:定义 ,再令 ,就得到归一化的亚阈值方程:

2.2

This describes only integration. The firing condition and reset must be specified separately. Together they define the complete hybrid dynamical system.它只描述积分阶段。放电条件 与复位 需要另行指定。两者组合后,才是完整的混合动力系统。

01

What happens when the input exceeds threshold?把输入推过阈值,会发生什么?

INTERACTIVE
膜电位 u / 归一化连续时间解析轨迹
膜电位阈值 / 输出事件
0.503.00
5 ms50 ms
理论稳态放电率
46.26 Hz
200 ms 内的输出事件
试一试:把 J 调到 θ 以下,膜电位仍会上升,但不再在有限时间内穿过阈值。图中固定 u(0) = uᵣ = 0、不应期 2 ms;事件时刻按恒定输入解析解计算。
Derivation A: integrating factors, exponential memory, and constant input推导 A:积分因子、指数记忆与恒定输入解 DERIVATION

Write the equation as and multiply by the integrating factor :把方程写成 ,乘以积分因子

2.3

Integrating from to gives: 积分到 ,得到:

2.4

This is exponentially weighted memory: old input persists, but its influence decays with time. For constant :这是一种指数加权记忆:旧输入不会立刻消失,但其影响随时间衰减。若 恒定:

2.5

Starting from reset value , with , set the voltage equal to threshold to solve for the integration time:从复位值 出发且 ,令电压等于阈值,解出积分到阈值所需时间:

2.6

Here excludes the refractory period; the actual interspike interval is . For time measured in milliseconds, multiply the frequency above by 1000 to obtain Hz. If and the initial voltage is below threshold, sustained threshold crossings do not occur in finite time.这里 不含不应期;实际相邻脉冲间隔为 。使用毫秒代入时,换算为 Hz 需要将上式乘以 1000。若 且初始电压低于阈值,则不会在有限时间内持续穿越阈值。

Discrete implementation: integrate, test, reset离散实现:先积分,再判断,再复位

Assuming constant input within each step, exact integration gives . Absorbing the input’s time-step factor into the weights yields the common discrete form:假设每一步内输入保持不变,精确积分得到 。把输入的时间步系数吸收到权重中,常用离散形式为:

2.7

Hard reset硬复位

2.8

After a spike, return directly to the specified potential. Any overshoot within the discrete step is discarded.放电后直接回到指定电位,离散步内的超调被丢弃。

Subtractive reset减法复位

2.9

With a zero reset baseline, subtract the threshold and retain the excess voltage after firing.此处取零复位基准;放电后保留超过阈值的“余量”。

Derivation B: discretization and closed-form propagation of exponential synapses推导 B:离散化与指数突触的闭式传播 DERIVATION

Exact one-step integration differs from Euler approximation精确单步积分与 Euler 近似不同

2.10
2.11

The leak factors are close only for a sufficiently small time step. State explicitly which discretization the implementation uses.只有时间步足够小时,两者的漏电系数才接近。必须明确代码使用哪一种。

Input spikes first enter the synaptic current输入脉冲先进入突触电流

Let , with each weight defined as a jump in synaptic current: ,并把权重定义为突触电流的跳变量:

2.12

Over an interval without a new event:在没有新事件的一段时间 内:

2.13

Substituting into the membrane-potential integral, for :把它代回膜电位积分式,在 时:

2.14

When , taking the limit gives: ,取极限得到:

2.15

This continuous-time, current-based model is also the starting point for the EventProp derivation below.[5]这一电流型连续时间模型也是后文 EventProp 推导的起点。[5]

训练的难点不是那条线性微分方程硬阈值 H 的普通导数几乎处处为零,阈值处不可微。但这不等于“所有 LIF 损失都没有梯度”:电压轨迹可有梯度,连续时间的脉冲时刻也可能可微。困难在于,不能把硬事件当成一个普通的光滑计算节点。[3][5]
03NEURON DYNAMICS / A SMOOTH MODEL神经元动力学 / 平滑模型

UltraLIF: make the forward model differentiable. (2026 preprint v1)UltraLIF:让前向模型本身可微。2026 预印本 v1

Instead of borrowing a derivative for a hard threshold, change the forward computation: integrate with a smooth maximum, emit soft spikes with a sigmoid, and differentiate this smooth system directly.[2]另一条路线不是给硬阈值“借一个导数”,而是改变神经元的前向计算:用平滑最大值做积分、用 sigmoid 输出软脉冲,再对这个平滑系统求真实导数。[2]

From addition to max, from multiplication to addition从加法到 max,从乘法到加法

Apply the dimensionless exponential transformations and to positive variables. Multiplication satisfies , while addition becomes:对正变量作无量纲指数变换 。乘法满足 ,而加法变为:

3.1

Set and factor out the largest exponential term: ,把最大的指数项提出来,就有:

3.2

As , LSE approaches max. This gives the max-plus structure: ordinary addition becomes a maximum, and ordinary multiplication becomes addition.因此 时,LSE 收敛到 max。这就是 max-plus 结构的来源:原来的“加”变成取最大值,原来的“乘”变成普通加法。

02

How does temperature change the forward map and its derivative?温度,怎样改变前向与导数?

INTERACTIVE
s(h) / 输出θ = 1
平滑前向硬阈值
0.03 / 更硬0.80 / 更软
阈值处的局部导数峰值
1.250
max(ds/dh) = 1 / (4ε)
LSE − max 的误差上界
0.1386
两个输入时:ε ln 2
观察重点:降低温度会让输出更接近硬阈值,却也让导数更窄、更尖。图中展示局部映射;完整 UltraLIF 还包含旧状态与输入之间的 LSE 积分,以及复位的导数。

The complete integrate–output–reset equations完整的积分—输出—复位方程

Following Definition 4.1 of the original paper, let and ; the reset potential is typically :采用原文定义 4.1,令 ,复位电位通常取

3.3

At finite temperature, : the output is continuous and soft, not strictly binary. This differs from a hard forward threshold with a surrogate backward derivative at the level of the forward model itself.[2]有限温度下 ,所以这是连续的软输出,而非严格二值脉冲。它与“前向硬阈值、反向代理导数”的区别,发生在前向模型本身。[2]

Derivation C: local derivatives of state, input, weights, and reset推导 C:旧状态、输入、权重与复位的局部导数 DERIVATION

Suppress time indices, let and , and define three local factors:省略时间下标,令 ,并定义三个局部因子:

3.4

Differentiating LSE:对 LSE 求导:

3.5

Differentiating the soft spike:对软脉冲求导:

3.6

Write the reset as . The product rule gives:复位写成 。乘积法则给出:

3.7

The local Jacobians for temporal and input propagation are therefore:所以时间传播与输入传播的局部 Jacobian 分别为:

3.8

If , the direct contribution at the current node is: ,则当前节点的直接贡献为:

3.9

These partial derivatives hold the preceding state fixed. The complete loss gradient must also accumulate the parameter’s influence through future time steps: the role of BPTT in the next section.这里所有偏导都固定先前状态。完整的损失梯度还要把参数经由未来时间步产生的影响加起来,也就是下一节的 BPTT。

Derivation D: why can temperature itself be learned?推导 D:温度为什么也可以学习? DERIVATION

Holding fixed, differentiate with respect to temperature:固定 ,直接对温度求导:

3.10

Using and , we obtain:利用 ,得到:

3.11

This is exactly the entropy of the binary distribution . Continuing with the chain rule:它正好是二元分布 的熵。继续使用链式法则:

3.12
3.13

Parameterize temperature as to keep it positive, giving . A temperature shared across time also accumulates contributions from every time step. 保证温度为正,即有 。同样,时间共享的温度参数需要累积所有时间步的贡献。

Two mathematical details worth checking separately两个值得单独核对的数学细节

① 零温极限是 max-plus 递推,不是标准加法 LIF

If the original positive-variable recurrence has a fixed leak coefficient , the exponential transformation produces a shift . UltraLIF uses a fixed shift , corresponding to a leak coefficient in the original coordinates, which varies with temperature.若原正变量递推的漏电系数固定为 ,指数变换产生的平移项应是 。UltraLIF 使用固定平移 ,对应原变量空间的漏电系数 ,会随温度变化。

3.14

For example, using the same numerical values and , with no spike, the left side is 1 and the right side is 1.5. This checks the recurrence algebra; it does not identify variables in different coordinates as the same physical quantity. A logarithmic transformation of positive variables also does not automatically cover signed inhibitory currents. Read the original definition and convergence proof relative to its max-plus target recurrence.[2]例如用相同数值的 且暂不放电,左侧为 1,右侧为 1.5。这是对递推式的代数核对,不是把两种坐标中的变量认作同一物理量。正变量对数变换也不能无条件覆盖有符号的抑制性电流。原文的定义与收敛证明应在其 max-plus 目标递推下阅读。[2]

② 全可微,不等于时间梯度永不消失或爆炸

For fixed , the sigmoid derivative is positive at finite states, yet it can approach zero arbitrarily far from threshold. Its threshold peak grows as temperature decreases. Temporal gradients additionally include the reset derivative.虽然固定 时,有限状态下 sigmoid 导数为正,但远离阈值它可以任意接近零;阈值处的峰值 又会随降温增大。更重要的是,时间梯度还乘上了复位导数。

3.15

Taking , , and gives . A reset expressed as a convex interpolation between two potentials does not imply a derivative bounded in magnitude by 1: the interpolation coefficient also depends on voltage. This counterexample and the parameter distinction above are direct algebraic checks of the definitions. ,可得 。所以“复位值是两个电位的凸插值”不意味着复位映射的导数绝对值不超过 1;插值系数本身也依赖电压。这一反例与上面的参数区别均为本文从定义直接计算得到。

04DIFFERENTIATION / THROUGH DISCRETE TIME求导 / 沿离散时间传播

BPTT: unfold time into a computation graph.BPTT:把时间,展开成一张计算图。

A neuron has a different state at each time. Represent each time step as a node, unfold the recurrence, and apply the chain rule backward: Backpropagation Through Time.[3]同一个神经元在不同时刻有不同状态。把每一个时刻复制成图中的一个节点,沿时间展开,再按链式法则逆向传播,就是 Backpropagation Through Time。[3]

UNROLLED COMPUTATION GRAPH / SHARED PARAMETERS展开的计算图 / 共享参数
z₁z₂z₃z₄z₅x₁ · Wx₂ · Wx₃ · Wx₄ · Wx₅ · WFFFFJ₅ᵀ a₅J₄ᵀ a₄J₃ᵀ a₃J₂ᵀ a₂
绿色:状态沿时间传播。橙色:误差通过 Jacobian 的转置返回。每个时间步都使用同一组参数 W,因此最终权重梯度需要把各步贡献求和。

The general backward recurrence最通用的反向递推

Let the state equation be and the loss . Define and , and let denote the gradient of all subsequent losses with respect to state :设状态方程 ,损失为 。定义 ,并令 表示全部后续损失对状态 的梯度:

4.1
4.2

The terminal condition is . This assumes that the initial state does not depend on the parameters; otherwise include the initial-state path as well.终点条件是 。这里默认初始状态不依赖参数;若依赖,还要加上初始状态路径的贡献。

03

How does a product change long-range gradients?一串乘法,怎样改变远期梯度?

INTERACTIVE
梯度幅值 |j|ᵏ / 对数纵轴标量 Jacobian 教学模型
回溯 k 步后的幅值单位梯度 1
0.201.40
432
回到最早状态时的梯度幅值
0.08953
旧状态的影响正在衰减。
不要混淆:这里把每一步 Jacobian 简化为同一个标量 j,用来展示连乘。真实 SNN 要乘的是含漏电、复位、阈值导数和连接权重的矩阵;这不是一条真实网络的训练曲线。

BPTT is not synonymous with a surrogate gradientBPTT 不等于代理梯度

When the forward map is differentiable, BPTT is the true chain rule for that discrete model. For hard LIF, a common approach retains hard spikes in the forward pass and replaces only the threshold derivative in the backward pass:[3]若前向映射真正可微,BPTT 就是该离散模型的真实链式法则。对硬 LIF,常见做法是保留前向硬脉冲,仅在反向替换阈值导数:[3]

4.3

The symbol denotes a deliberate replacement, not equality. UltraLIF instead uses from the previous section as a true local derivative, propagated through the same temporal computation graph.符号 表示人为替代,而非真实相等。UltraLIF 则使用上一节的 作为真实局部导数,再沿同一套时间计算图反传。

Derivation E: spatial and temporal BPTT for LIF, and weight gradients推导 E:LIF 的时空 BPTT 与权重梯度 DERIVATION

Consider layer with subtractive reset:考虑第 层,采用减法复位:

4.4

Let , and let be the direct loss gradient with respect to . Here g is a loss derivative, not the sigmoid derivative from the previous section. Along the temporal path: 表示损失对 的直接梯度;此处 g 是损失导数,不是上一节的 sigmoid 导数。时间路径上:

4.5

Along the spatial path, depends on this layer’s output through . Adding both paths and the direct loss contribution:空间路径上, 通过 依赖本层输出。把两条路径与直接损失相加:

4.6

The first line propagates between layers; the second propagates through time. Consequently:第一行是层间反传;第二行是时间反传。于是:

4.7

Explicit recurrent connections显式循环连接的情况

If , let . Under subtractive reset: ,令 。减法复位下:

4.8
4.9
4.10
Derivation F: hard reset, subtractive reset, and detached reset推导 F:硬复位、减法复位与 detach reset IMPLEMENTATION

Reset changes both the forward trajectory and the temporal Jacobian. The backward derivative of hard reset is:复位不仅影响前向轨迹,也改变时间 Jacobian。硬复位的反向导数为:

4.11

For subtractive reset:减法复位则为:

4.12

If only the spike s in the reset branch is detached, the hard-reset derivative becomes , and the subtractive-reset derivative becomes 1. This does not detach spike gradients everywhere in the network. Record detached reset as an explicit modeling and implementation choice, not an inconsequential optimization.若仅对复位分支中的脉冲 s 停止梯度,硬复位变成 ,减法复位变成 1。注意这不意味着整个网络中脉冲的梯度都被停止。是否 detach reset 必须作为明确的实现选择记录,不能当作无关紧要的优化。

ONE IMPORTANT DISTINCTION一个重要区别
“沿时间反传”是计算框架。
“用什么导数”才决定你在优化哪个模型

Hard forward spikes with a surrogate derivative and soft forward spikes with a true derivative may produce similar-looking backward code, but their mathematical meanings differ.硬前向 + 代理导数,与软前向 + 真实导数,可能使用外观相似的反向代码,但其数学含义并不相同。

05PLASTICITY / LOCAL TIMING RULES可塑性 / 局部时序规则

STDP: milliseconds of timing change a synapse.STDP:先后几十毫秒,改变一条突触。

Spike-Timing-Dependent Plasticity asks a local question: which neuron fires first, the presynaptic or the postsynaptic one? Here we consider the common pair-based exponential Hebbian window, not a universal rule for every biological synapse.[4]Spike-Timing-Dependent Plasticity 关注一个局部问题:突触前、后神经元,谁先放电?下面讨论最常用的双脉冲指数窗口、Hebbian 型规则,而不是声称所有生物突触都服从同一窗口。[4]

Define . Presynaptic-before-postsynaptic timing is positive; the reverse is negative. A single pair produces the weight change :定义 。前先后放为正,后先前放为负。一次配对产生的权重变化为

5.1
04

Swap the order of two spikes.让两个脉冲交换先后顺序。

INTERACTIVE
A(Δ) = Δw / η双脉冲、指数窗口
后先前放前先后放
10 ms50 ms
图中 τ₊ = τ₋ = τ
A₊ = 1,A₋ = 1.05
当前配对的 Δw / η
+0.6065
突触前先放,权重增强。
试一试:让 Δ 穿过 0,更新会由减弱切换为增强;增大 τ,较远的脉冲配对也会产生明显影响。本实验约定同一时刻的零延迟配对不更新,即 A(0) = 0。

The exponential window comes from spike traces指数窗口并不神秘:它来自脉冲痕迹

Let the presynaptic trace and postsynaptic trace increase by 1 on a spike and decay exponentially between spikes:令突触前痕迹 与突触后痕迹 在脉冲到来时增加 1,在脉冲之间指数衰减:

5.2

At a postsynaptic spike, read the presynaptic trace and potentiate. At a presynaptic spike, read the postsynaptic trace and depress:当突触后神经元放电时,读取前痕迹并增强;当突触前神经元放电时,读取后痕迹并减弱:

5.3

Reading the trace at means the current spike has not yet been added. This makes the convention for simultaneous spikes explicit. Trace-based updates are a common local implementation of pair-based STDP.[4]读取 的痕迹,表示当前脉冲还没写入。这使同一时刻脉冲的配对约定保持明确。痕迹式是局部实现成对 STDP 的常见方式。[4]

Derivation G: recover the pair window from local traces, then discretize推导 G:从局部痕迹恢复配对窗口与离散实现 DERIVATION

With zero initial conditions:零初始条件下:

5.4

If the presynaptic spike occurs first, its trace at the postsynaptic spike is , yielding the positive window. In the reverse order, the presynaptic spike reads , with a negative sign. Integrating over multiple spikes gives:若前脉冲先发生,在后脉冲到来时,前痕迹值为 ,因此得到正向窗口。若后脉冲先发生,前脉冲到来时读取到 ,并乘上负号。多脉冲时积分得到:

5.5

This implements all-to-all pairing; it is not automatically a nearest-neighbor rule.这对应 all-to-all 配对,不自动等于只保留最近一对脉冲。

The correct order in a discrete implementation离散实现的正确顺序

Let . First decay the traces, then update the weight, then insert the current spikes: 。先衰减,再更新权重,最后写入当前脉冲:

5.6

This excludes zero-delay pairs within the same time bin. Coarse bins can erase the actual ordering, so temporal resolution is itself a modeling choice.这种写法不计同一时间格的零延迟配对。时间格太粗会抹去真实的先后顺序,因此时间分辨率本身就是模型选择。

Derivation H: correlation learning, weight drift, and three-factor rules推导 H:相关性学习、权重漂移与三因子规则 DERIVATION

For stationary spike processes, define cross-correlation density . The mean update is:对平稳脉冲过程定义互相关密度 。平均更新为:

5.7

When pre- and postsynaptic activity are independent with rates , we have , hence:当前、后活动独立且发放率为 时, ,于是:

5.8

Uncorrelated activity can still cause systematic drift. Additive STDP does not inherently keep weights bounded. With and , the mean fixed point under independent activity is:不相关活动也可能导致系统性漂移。加性 STDP 不会天然把权重限制在有限范围。若改用 ,独立活动近似下的平均固定点为:

5.9

A third factor: how good was the outcome?第三个因子:结果好不好?

Local pre- and postsynaptic activity does not directly know the task loss. One can maintain an eligibility trace e and gate it with a reward or modulatory signal M:[6]局部的前、后活动不直接知道任务损失。可以先维护资格痕迹 e,再用奖励或调制信号 M 门控:[6]

5.10

This provides a mechanism for delayed feedback, but an arbitrary three-factor rule is not automatically an exact gradient. A gradient interpretation requires a specified probabilistic model, loss, and eligibility trace.这为延迟反馈提供一种机制,但任意三因子规则也不自动等于精确梯度。是否可解释为梯度,需要明确概率模型、损失与资格痕迹的定义。

Ordinary STDP普通 STDP

Presynaptic activity times a postsynaptic local trace: this defines a learning rule.突触前活动 × 突触后局部痕迹。
它定义的是一种学习规则。

BPTT / EventProp

Presynaptic activity times an error signal propagated from the loss: these methods address gradient computation.突触前活动 × 从损失反传的误差信号。
它们解决的是梯度计算问题。

06DIFFERENTIATION / THROUGH CONTINUOUS EVENTS求导 / 穿过连续时间事件

EventProp: differentiate when the threshold is crossed, rather than the hard threshold itself.EventProp:不去求硬阈值的导数,
而去求“何时越过阈值”。

A spike is a discrete event, but its time can move continuously with a weight. EventProp uses implicit differentiation to track that shift, then propagates event-related errors backward with an adjoint method.[5]一个脉冲看起来是离散事件,但它发生的时间,可以随着权重连续移动。EventProp 用隐式求导追踪这个时间变化,再用伴随法把事件处的误差信号反传。[5]

An implicit equation opens the door to event gradients一条隐式方程,打开事件梯度的入口

Suppose neuron n reaches threshold at :设第 n 个神经元在 达到阈值:

6.1

A parameter change affects both voltage and event time. Differentiate the equation with respect to both:参数改变时,电压和事件时间都会变。对上式同时求导:

6.2
6.3
分子:参数敏感度在固定时刻,改变权重会把电压推高或压低多少?
分母:越过阈值的速度电压轨迹越平,达到阈值的时刻对扰动越敏感。
05

How much earlier does the spike occur after a small weight change?轻轻改变权重,脉冲会提前多少?

INTERACTIVE
膜电位 u / 归一化首次脉冲的解析解
原权重 ww + 0.02未复位参考
解析梯度与中心差分核验
3.008.00
损失 ℒ = ½(t* − tₜₐᵣ)²
首次放电时刻 t*
6.470 ms
dt*/dw = −2.472 ms / 权重单位
损失对权重的梯度
+3.7820
梯度下降将减小权重,使放电延后。
模型与边界:τₘ = 20 ms,τₛ = 10 ms,θ = 1;t = 0 的外部事件使 J 跳变到 w。实线仅画到首次放电,虚线是“没有复位”的参考延拓。本实验直接核验事件时刻导数,未实现完整网络的伴随求解器。

Why does resetting voltage to zero not erase the gradient?为什么复位到零,梯度却不归零?

The reset condition is . Its derivative must still account for the moving event time:复位条件为 。仍然必须把事件时间的移动一起求导:

6.4

Trajectories with slightly different parameters reset at different times. At the same absolute time, they have therefore undergone different durations of post-reset evolution. Differentiating only the assignment “set voltage to zero” misses this temporal path.[5]两条参数略有不同的轨迹,会在不同的时刻复位。在同一个绝对时刻比较时,它们已经经历了不同长度的复位后演化。只对“把电压设成零”这个赋值求导,会遗漏这条时间路径。[5]

Derivation I: hybrid systems and the saltation matrix推导 I:混合系统与跳跃敏感度矩阵 DERIVATION

Assume current-based LIF without self-connections or delays; fixed initial state, threshold, and time constants; and isolated events that cross the threshold transversally from below:以下采用无自连接、无延迟、电流型 LIF,固定初始状态、阈值和时间常数,并假设事件彼此孤立、从下方横截穿越阈值:

6.5

Write the state as , inter-event dynamics as , the event condition as , and the jump as . Let ; here n is the event normal, not the neuron index used earlier.把状态写成 ,事件之间 ,事件条件 ,跳变 。令 ,这里 n 是事件法向量,不是前文的神经元编号。

The event condition gives the time perturbation:由事件条件,时间扰动为:

6.6

Advance the perturbed trajectory to its shifted event, apply the reset, then align the post-event trajectory to the same reference time:先把扰动轨迹推进到移动后的事件,施加复位,再把事件后的轨迹对齐到同一参考时刻:

6.7

Substitution of the time perturbation gives the saltation matrix:代入时间扰动,得到跳跃敏感度矩阵,又称 saltation matrix:

6.8

The second term corrects for the moving event time. Here the event condition has no direct parameter dependence. Learnable thresholds or explicitly time-dependent event conditions require additional terms.第二项正是事件时间移动的修正。这里事件条件不直接依赖参数;若阈值可学习或事件条件显含时间,公式需添加相应项。

The adjoint method: avoid tracking every weight separately伴随法:让梯度计算不必逐个追踪每条权重

Maintaining state sensitivities for every weight is expensive. The adjoint method introduces backward variables for voltage and current, eliminating parameter sensitivities through reverse-time equations and event jumps. The following uses the original paper’s normalization and signs.[5]直接为每个权重维护状态敏感度,代价很高。伴随法引入与电压、电流状态对应的反向变量 ,通过逆时间方程与事件跳跃消去这些参数敏感度。以下采用原文的归一化和符号约定。[5]

6.9

Here denotes differentiation in reverse time. Without an explicit terminal-state loss, . At each forward spike time, apply a backward jump rather than integrating smoothly across the event.这里 是反向时间导数。没有显式终端状态损失时, 。在每次前向放电的时刻,还需要施加反向跳跃,而不是平滑地一路积分过去。

Derivation J: augmented loss, integration by parts, and adjoint jumps推导 J:增广损失、分部积分与伴随跳跃 FULL DERIVATION

Take the loss:取损失:

6.10

Within each inter-event interval, add dynamical constraints that evaluate to zero:在每个事件间隔内加入为零的动力学约束:

6.11

Differentiate with respect to the parameters, then integrate by parts the terms containing time derivatives of state sensitivities. The coefficients of voltage and current sensitivities are:对参数求导,对含状态敏感度时间导数的项分部积分。电压敏感度和电流敏感度前的系数分别为:

6.12

Set both coefficients to zero and rewrite in reverse time to recover the inter-event adjoint equations above.令两者为零,再改写为逆时间,得到正文中的事件间伴随方程。

What remains at the event?事件处还剩什么?

Let . The moving integration boundary and integration by parts together produce: 。移动积分边界与分部积分共同产生:

6.13

Insert the event-time derivative and sensitivity jump, and eliminate coefficients of the unknown sensitivities. The current adjoint is continuous, as is the voltage adjoint for neurons that did not fire:代入事件时刻导数与状态敏感度跳跃,让未知敏感度前的系数消失。电流伴随连续,未放电神经元的电压伴随连续:

6.14

The voltage adjoint of the firing neuron n jumps according to:放电神经元 n 的电压伴随跳跃为:

6.15

The four numerator terms represent self-reset, the spike’s effect on the postsynaptic network, direct spike-time loss, and movement of the integration boundary. The denominator again comes from implicit differentiation of the threshold event. This jump condition carries the backward calculation through a hard event.分子中的四部分依次对应:自身复位、输出脉冲对突触后网络的影响、脉冲时刻直接损失、积分边界移动。分母仍来自阈值事件的隐式求导。这个跳跃条件才让反向计算“穿过”硬事件。

The final weight gradient accumulates only at input events最终的权重梯度,只在输入事件上累加

When neuron j fires, ; the jump map’s direct derivative with respect to the weight is 1. Once the adjoint equations eliminate state sensitivities, the direct event contributions remain:神经元 j 放电时, ,权重在跳跃映射中的直接偏导为 1。伴随方程消去状态敏感度后,剩下每次事件的直接贡献:

6.16

This resembles “presynaptic event times postsynaptic signal.” Here, however, the postsynaptic signal is an adjoint propagated from the global loss, not the local spike trace in ordinary STDP. The minus sign and come from this section’s adjoint normalization; defining expresses the gradient as a sum of over events.[5]它的外形像“突触前事件 × 突触后信号”。但这里的突触后信号是从全局损失反传的伴随变量,而不是普通 STDP 的局部脉冲痕迹。负号与 来自本节采用的伴随归一化;若定义 ,上式就写成对 的事件求和。[5]

Derivation K: the experiment’s closed form and finite-difference check推导 K:交互实验的闭式解与有限差分核验 NUMERICAL CHECK

At t = 0, a fixed external event raises current from zero to w while voltage stays zero. Taking and , before the first spike:t = 0 的固定外部输入事件使电流从零跳到 w,电压仍为零。取 ,首次放电前:

6.17

The maximum of K is 1/4. At threshold 1, only produces a first crossing from below. Let ; then:这里 K 的最大值为 1/4;阈值取 1 时,只有 才有从下方穿越阈值的首次事件。令 ,则:

6.18

Choose the larger root to select the first crossing on the rising branch. Implicit differentiation gives:使用较大的根,选择上升段的首次穿越。隐式求导得到:

6.19

At the default weight w = 5 and target time 8 ms:在默认值 w = 5、目标时刻 8 ms 时:

6.20

The experiment compares the analytic gradient with the central difference , using . It displays a check only when both perturbations preserve the same first-crossing event.实验将解析梯度与中心差分 比较,取 ,且仅在两侧都保有同一首次穿越事件时显示核验结果。

Python / 标量首次事件梯度
import math


def first_spike_time(w: float) -> float:
    """tau_m=20 ms, tau_s=10 ms, theta=1; ascending crossing."""
    if not math.isfinite(w) or w <= 4.0:
        raise ValueError("需要 w > 4,才能定义横截穿越的首次事件")
    y = (1.0 + math.sqrt(1.0 - 4.0 / w)) / 2.0
    return -20.0 * math.log(y)


def event_gradient(w: float, target: float = 8.0) -> float:
    if not math.isfinite(target):
        raise ValueError("目标时刻必须为有限数值")
    t = first_spike_time(w)
    k = math.exp(-t / 20.0) - math.exp(-t / 10.0)
    dk = -math.exp(-t / 20.0) / 20.0 + math.exp(-t / 10.0) / 10.0
    return -(t - target) * k / (w * dk)


w, target, h = 5.0, 8.0, 1e-5
loss = lambda q: 0.5 * (first_spike_time(q) - target) ** 2
finite_difference = (loss(w + h) - loss(w - h)) / (2.0 * h)
print(event_gradient(w, target), finite_difference)
# 两者均约为 3.78202;不是完整 EventProp 网络实现。
“精确”有明确的适用边界

The gradient applies to the specified hybrid system while event structure is locally unchanged and the threshold crossing is transversal. Event appearance or disappearance, changes of event order, and tangencies can be nondifferentiable; simultaneous events need separate analysis. Numerical implementations still incur event-location and integration error.[5]这里指对指定混合系统,在事件结构局部不变、阈值被横截穿越时成立的梯度。脉冲出现或消失、事件次序变化、切触阈值等临界点可能不可微;同时事件需额外分析。数值实现仍存在事件定位和积分误差。[5]

Set w = 4: the peak just touches threshold, the crossing velocity vanishes, and the derivative’s denominator disappears. For w < 4 there is no event, hence no first-spike time for this loss to differentiate. An event-time gradient cannot be assigned to a spike that does not exist.把实验权重调到 w = 4:电压峰值刚好触及阈值,但穿越速度为零,公式分母消失。w < 4 时没有该事件,也就没有可供这个损失求导的首次放电时刻。不能给“尚不存在的脉冲”硬套上事件时间梯度。

For memory usage, event-based recording is possible under the original paper’s assumptions, such as losses depending only on spike times. Continuous voltage losses require additional trajectory storage or reconstruction. Memory requirements therefore cannot universally be described as depending only on the number of spikes.[5]内存方面,原文在损失只依赖脉冲时刻等条件下可按事件记录;含连续电压损失时,还要存储或重建额外轨迹信息。因此不能把所有实现的内存需求一概说成只与脉冲数有关。[5]

07PUTTING IT ALL TOGETHER把概念联系起来

Learning spikes: different interventions, different assumptions.同样是学习脉冲,
改变的“位置”却不一样。

Separate the forward model, backward differentiation, and local plasticity, and many apparent contradictions disappear. This is a comparison of mathematical roles and conditions, not a performance ranking.把前向模型、反向求导和局部可塑性分开,很多表面矛盾就消失了。下面比较的是数学角色与适用条件,不是性能排名。

概念它规定什么关键结构应保留的限定
LIF神经元的前向动力学线性 ODE + 阈值 + 复位本身不规定怎么训练。[1]
UltraLIF平滑的前向模型LSE + sigmoid + 连续复位有限温度是软输出;硬极限为 max-plus 递推。[2]不能无条件等同标准加法 LIF。
BPTT时间展开图上的求导链式法则 + Jacobian 连乘SG-BPTT 使用代理局部导数;BPTT 本身不要求代理。[3]
STDP局部突触权重更新前后时序 + 痕迹变量通常不等于全局任务损失的精确梯度。[4]
EventProp连续硬事件系统的求导事件时间隐式导数 + 伴随跳跃非临界事件结构下精确,仍受数值求解误差影响。[5]
01 / CHANGE THE BACKWARD RULE01 / 改变反向规则

SG-BPTT: change the backward derivativeSG-BPTT:改反向导数

Keep hard spikes in the forward pass and supply a useful surrogate signal for the nondifferentiable threshold in the backward pass.前向依旧是硬脉冲,反向为不可微阈值提供一个可用的代理信号。

02 / CHANGE THE FORWARD MODEL02 / 改变前向模型

UltraLIF + BPTT: change the forward modelUltraLIF + BPTT:改前向模型

Smooth the dynamics, then use the actual derivatives of that smooth model.把动力学平滑化,再使用该平滑模型实际具有的导数。

03 / DIFFERENTIATE EVENT TIMES03 / 对事件时间求导

EventProp: differentiate event timesEventProp:对事件时间求导

Keep hard events while tracking when spikes occur and how sensitivities jump across reset.保留硬事件,同时追踪脉冲何时发生,以及复位前后的敏感度跳跃。

04 / DEFINE LOCAL PLASTICITY04 / 定义局部可塑性

STDP: define local plasticitySTDP:定义局部可塑性

Specify updates directly from relative spike timing, rather than assuming derivation from a global loss.根据脉冲的相对时序直接指定更新,而非默认从一个全局损失推导。

THE IDEA TO TAKE AWAY需要记住的思路
连续的状态,离散的事件,
还有连接它们的导数

Understanding SNNs means more than memorizing update equations: identify the dynamical system, whose gradient is being computed, and why the weights should change.理解 SNN,不只是记住几条更新公式,更是确认:你描述的是哪个动力系统,你计算的是谁的梯度,你希望权重为什么而改变。

08REFERENCES & REPRODUCIBILITY参考资料与可复现性

Return to the primary definitions.回到原始定义。

Sources checked on September 22, 2026. The note re-derives equations in consistent notation; its interactive plots are educational calculations, not reproductions of paper benchmarks. UltraLIF qualifications and counterexamples are explicitly identified as algebraic checks rather than unconditional claims about the preprint.来源核对日期:2026 年 9 月 22 日。正文用统一符号重新推导;交互图表为按文中方程计算的教学示例,不是论文基准实验的复现。UltraLIF 的限定和反例单独标为代数核对,避免将预印本主张直接当作不加条件的结论。

[1]
Neuronal Dynamics · §1.3 Integrate-And-Fire Models ↗W. Gerstner, W. M. Kistler, R. Naud, L. Paninski · Cambridge University Press, 2014
RC 电路、膜时间常数、LIF 的阈值与复位定义。本文 LIF 解析解由该方程推导。
[2]
UltraLIF: Fully Differentiable Spiking Neural Networks via Ultradiscretization and Max-Plus Algebra ↗Jose Marie Antonio Miñoza · arXiv:2602.11206v1 · 2026-02-10 · 预印本
重点对应定义 4.1、温度参数化与 max-plus 推导。本文不将其“全可微”自动解释为全局梯度稳定性保证。
[3]
Surrogate Gradient Learning in Spiking Neural Networks ↗Emre O. Neftci, Hesham Mostafa, Friedemann Zenke · 2019 · arXiv:1901.09948
硬阈值训练中的困难、代理梯度与时序反向传播。本文给出统一符号下的链式法则展开。
[4]
Neuronal Dynamics · §19.2 Models of Hebbian Learning ↗W. Gerstner et al. · 2014 · 在线教材
成对 STDP、局部痕迹与权重依赖规则。可视化采用明确的零延迟不更新约定。
[5]
Event-Based Backpropagation can compute Exact Gradients for Spiking Neural Networks ↗Timo C. Wunderlich, Christian Pehle · 2021 · Scientific Reports · arXiv:2009.08378
电流型 LIF、事件时间敏感度、伴随方程、跳跃条件与事件式权重梯度。交互实验只核验首次事件导数。
[6]
Neuronal Dynamics · §19.4 Reward-Based Learning ↗W. Gerstner et al. · 2014 · 在线教材
资格痕迹、奖励调制与三因子学习的背景。
Computation, offline reading, and reproducibility本页的计算、离线阅读与复现说明 ABOUT THIS PAGE

LIF: the continuous-time analytic solution for constant input, with explicit threshold-event timing and a 2 ms refractory period before restarting. The event count over the 200 ms window and theoretical steady-state rate are calculated separately.LIF:恒定输入的连续时间解析解;显式定位到阈值的事件,再按 2 ms 不应期重启。图示 200 ms 的有限窗口事件数与理论稳态频率分别计算。

UltraLIF: numerically stable log-sum-exp, with views for soft spikes, LSE, and actual local derivatives. Temperature stays positive; a finite-temperature curve is not presented as the hard limit.UltraLIF:稳定的 log-sum-exp 实现;可切换软脉冲、LSE 和真实局部导数。图中温度始终为正,不把有限温度画成硬极限。

BPTT: a constant scalar Jacobian product on a logarithmic vertical axis; no network training, dataset, or performance measurement.BPTT:恒定标量 Jacobian 的乘积示例,采用对数纵轴;无真实网络训练、数据集或性能测量。

STDP: a single spike pair, an exponential window, and no update at zero delay. The plot shows only Δw/η, without weight clipping, network feedback, or steady-state training.STDP:单次脉冲配对,指数窗口,零延迟不更新。图中只展示 Δw/η,不包含权重裁剪、神经元网络反馈或稳态训练。

EventProp: a fixed single-input first-crossing problem checked using both a closed form and central finite differences. No event, threshold tangency, and valid transversal crossings are distinguished explicitly.EventProp:固定的单输入首次穿越问题,以闭式解与中心差分交叉核验。明确区分未放电、切触临界点和有效横截事件。

Offline and privacy: the article HTML contains its equation vectors and experiment code; the published site also loads shared styles, scripts, and formula fonts from this site. Save the page together with its resources for offline reading. There is no tracking. Clicking Run & verify sends the displayed Python example to Godbolt; reference links lead to external sites.离线与隐私:文章 HTML 包含公式矢量图与实验代码;发布后的页面还会从本站加载共享样式、脚本和公式字体。离线阅读时需要连同页面资源一起保存。没有追踪。自动语言选择可能请求 Country 查询 IP 所在地区;本站不保存 IP。点击“运行验证”会把所示 Python 示例发送给 Godbolt;参考文献链接会访问外部网站。

Printing: printing preserves the current expansion state. Open the derivations you want to include, then use Print / Save PDF or the browser’s print command.打印:打印会保留当前展开状态。先展开需要包含的推导,再使用“打印/保存 PDF”或浏览器的打印功能。

脉冲之间 / SPIKE NOTES
把公式变成可以观察、可以操作的直觉。