Tutorial 75: Spike Normalization¶
5 SNN-specific batch normalization variants. Standard BN fails in SNNs because spike activations are binary and statistics shift across timesteps. These normalizers handle temporal dynamics, threshold interaction, and inference re-parameterization (zero-overhead deployment).
No other SNN library ships these as reusable modules.
The Problem¶
Standard batch normalization assumes continuous activations with stable statistics. SNNs violate both assumptions: activations are binary spikes, and the distribution changes at every timestep (temporal covariate shift). Naively applying BN to SNNs degrades accuracy by 5-15% on CIFAR-10 (Zheng 2021).
Available Normalizers¶
| Normalizer | Key Idea | Reference |
|---|---|---|
ThresholdDependentBN |
Incorporates firing threshold into normalization | Zheng 2021 |
PerTimestepBN |
Separate BN statistics per timestep | Kim & Panda 2021 |
TemporalEffectiveBN |
Per-timestep scaling factor on top of BN | Duan 2022 (NeurIPS) |
MembranePotentialBN |
BN on membrane, folds into threshold at inference | Guo 2023 (ICCV) |
TemporalAccumulatedBN |
Normalizes accumulated membrane across time | Jiang 2024 (ICLR) |
Quick Start¶
import numpy as np
from sc_neurocore.spike_norm import (
ThresholdDependentBN,
PerTimestepBN,
TemporalEffectiveBN,
MembranePotentialBN,
TemporalAccumulatedBN,
)
# Simulated batch of presynaptic currents: (batch=32, features=64)
rng = np.random.RandomState(42)
x = rng.randn(32, 64)
# tdBN: threshold-aware normalization
tdbn = ThresholdDependentBN(n_features=64, threshold=1.0)
x_norm = tdbn.forward(x, training=True)
# BNTT: different statistics per timestep
bntt = PerTimestepBN(n_features=64, T=10)
for t in range(10):
x_t = rng.randn(32, 64)
out_t = bntt.forward(x_t, t=t, training=True)
# MPBN: fuse into threshold at inference (zero overhead)
mpbn = MembranePotentialBN(n_features=64, threshold=1.0)
for _ in range(100):
mpbn.forward(rng.randn(32, 64), training=True)
hw_thresholds = mpbn.fused_threshold() # shape (64,)
# No BN computation at inference — threshold absorbs it
MPBN: Zero-Overhead Inference¶
MembranePotentialBN is recommended for hardware deployment. At inference, BN
parameters fold into a per-neuron threshold:
new_threshold[i] = (V_th - beta[i]) * sqrt(var[i] + eps) / gamma[i] + mean[i]
Identical behavior to training BN with zero compute overhead.
API Reference¶
sc_neurocore.spike_norm.normalizers
¶
5 SNN normalization variants. No framework ships these as reusable modules.
tdBN: threshold-dependent BN (Zheng 2021) BNTT: per-timestep BN (Kim & Panda 2021) TEBN: temporal effective BN (Duan 2022, NeurIPS) MPBN: membrane potential BN with inference re-parameterization (Guo 2023, ICCV) TAB: temporal accumulated BN (Jiang 2024, ICLR)
ThresholdDependentBN
dataclass
¶
tdBN: incorporates firing threshold into normalization.
BN(x) = gamma * (x - mean) / sqrt(var + eps) + beta where mean/var are computed across batch, adjusted by V_threshold.
Parameters¶
n_features : int threshold : float momentum : float
Source code in src/sc_neurocore/spike_norm/normalizers.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | |
PerTimestepBN
dataclass
¶
BNTT: separate BN statistics per timestep.
Each timestep t has its own mean_t, var_t, gamma_t, beta_t.
Parameters¶
n_features : int T : int Number of timesteps.
Source code in src/sc_neurocore/spike_norm/normalizers.py
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | |
TemporalEffectiveBN
dataclass
¶
TEBN: rescales presynaptic inputs per timestep.
Applies BN then per-timestep scaling factor lambda_t.
Parameters¶
n_features : int T : int
Source code in src/sc_neurocore/spike_norm/normalizers.py
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 | |
MembranePotentialBN
dataclass
¶
MPBN: BN on membrane potential before spike function.
At inference: fold BN into threshold (zero overhead). new_threshold = (V_th - beta) * sqrt(var + eps) / gamma + mean
Parameters¶
n_features : int threshold : float
Source code in src/sc_neurocore/spike_norm/normalizers.py
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 | |
fused_threshold()
¶
Compute per-neuron threshold that absorbs BN at inference.
Returns ndarray of shape (n_features,) — use as per-neuron threshold instead of applying BN at inference (zero overhead).
Source code in src/sc_neurocore/spike_norm/normalizers.py
170 171 172 173 174 175 176 177 178 | |
TemporalAccumulatedBN
dataclass
¶
TAB: normalizes accumulated membrane potential.
Tracks running accumulated potential across timesteps. Addresses Temporal Covariate Shift directly.
Parameters¶
n_features : int
Source code in src/sc_neurocore/spike_norm/normalizers.py
181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 | |