1. Three places an SNN can keep the past
Eligibility-based online learning rules maintain synaptic traces that can be combined with a learning signal (Bellec et al., 2020). Here I consider a different constraint: each decision receives its own label after a simulated delay of 5–60 minutes.
The experiments use SHA-256-verified CHB-MIT scalp EEG from 12 CHB-MIT case records (11 unique individuals) studied in FGL (369 EDF files, 456.3 hours, 73 seizures). CHB-MIT file numbering is not always chronological, so I rebuilt absolute timelines directly from EDF header timestamps. Every 5-second frame extracts 10 causal features across 18 bipolar channels (D = 180): six log band powers (δ, θ, α, β, γ, high-γ skipping 60/120 Hz), forward-only 0.5–45 Hz log variance and line length, plus Hjorth mobility and complexity. Six frames form a 30-second window fed into a compact 2-layer snnTorch LIF network (SNNForecaster, 15,811 parameters, Eshraghian et al., 2023): fc1(180→64) → LIF1 → fc2(64→64) → LIF2 → rate h → σ(w·h + b).
chb13 Scalp EEG Across a Seizure OnsetTop: Channel-averaged causal delta power, beta power, and line length around chb13's first seizure. Bottom: The causal 2-bit delta spike raster (ON = +1 green, OFF = −1 red, silent = 0 cream) that feeds our SNN with binary/ternary synaptic accumulation in Section 6.
When the model scores window j at time t_j, the label y_j ∈ {0, 1} is not yet available. Under binary cross-entropy, the gradient for any parameter θ is linear in y_j: ∇_θ L_j = (p_j - y_j) ∇_θ z_j. Because snnTorch detaches the reset term and Layer 2 has no lateral recurrence in the feedforward version, backprop through time for W_2 factors exactly (checked against PyTorch autograd to <10−6 in tests/test_plasticity.py):
For a backlog of B_delay pending decisions, dense eligibility storage scales as O(B_delay · N_in · N_out) floating-point values. The complete payload is 16,908 bytes per decision. Packed binary Layer-1 activity scales as O(B_delay · N_in · T) bits; with a timestamp, this is 56 bytes per decision. Replaying the retained spikes reconstructs the Layer-2 gradient at the current weights, reducing the buffer payload by a factor of 302.
Every learner sees the exact same chronological EEG stream and label arrival timestamps. Toggle the four buttons above to compare stored payload, peak buffer payload at D = 15 min (backlog 241), and plastic layers.
chb13 Seizure Window Across All Three Memory SpacesLeft: Real causal z-scored EEG window X (4,328 B). Middle: Exact 64×64 Layer-2 eligibility |E_bar| (16,908 B). Look at the plaid stripes in the middle plot: every active vertical column matches the green Layer-1 spikes on the right (56 B), showing straight away why E_bar collapses to rank 1.
| Memory Space & Method | Stored Payload per Pending Decision | B / dec | Peak (15m) | Peak (60m) | vs. e-prop |
|---|---|---|---|---|---|
| Weight: Full L1+L2 e-prop (theory) | fp32 E_1 (64×180) + E_2 (64×64) + biases + h, p, t |
63,244 | 14.88 MiB | 48.24 MiB | 0.27× |
Weight: Recurrent RLeaky e-prop |
fp32 E_in + E_rec (two 64×64) + E_b, h, p, t (approx) |
33,292 | 7.84 MiB | 25.39 MiB | 0.51× |
Weight: Exact LIF L2 e-prop (E_bar) |
fp32 E_bar (64×64) + E_b + h + p + t |
16,908 | 3.98 MiB | 12.89 MiB | 1.0× |
| Input: Full-Net BPTT (fp32) | fp32 causal window X (6×180) + t |
4,328 | 0.995 MiB | 3.30 MiB | 3.9× |
Weight: Block-10 (L=10) |
Per-block sums ΣE_bar, ΣpE_bar (skip mixed) |
3,380 | 825 KiB | 2.64 MiB | 4.8× |
| Weight: SVD Rank-1 (fp16) | Top singular triplet u_1, σ_1, v_1 + E_b, h (fp16) |
526 | 123.8 KiB | 401.0 KiB | 32.1× |
| Spike: E2E 2-bit Delta / Bipolar | Bit-packed ON/OFF spikes (270 B) + t (add/sub synapses, all layers) |
278 | 65.4 KiB | 212.0 KiB | 227× full |
| Spike: E2E 1-bit Sign | Bit-packed binary spikes (135 B) + t (add/sub synapses, all layers) |
143 | 33.7 KiB | 109.1 KiB | 442× full |
Weight: Unaligned Trace (O(1)) |
Single decaying E_run, pE_run (τ=15m) |
— | 33.0 KiB | 33.0 KiB | 120× |
| Spike: Binary L1 Replay (L2+H) | Bit-packed Layer-1 spikes s_1 (48 B) + t (8 B) |
56 | 13.2 KiB | 42.7 KiB | 302–595× |
| Control: Bias-Only (1 param) | Scalar p_j + t_j (global risk offset only) |
12 | 2.8 KiB | 9.1 KiB | 1,409× |
2. Low-rank eligibility compression
To compare replay against compressed eligibility, I use the factorization E_bar = (1/T) Σ_t ψ(t) ε(t)ᵀ. Since T = 6, the rank is at most six. Thin QR decompositions of the two 64×6 factors reduce the SVD to a 6×6 matrix. The implementation reports approximately 20× faster decomposition and agreement with the dense SVD to 10⁻¹¹.
Across 328,041 EEG windows, the mean singular values are σ₁ = 7.758, σ₂ = 0.452 and σ₆ = 0.048. Rank 1 accounts for 99.50% of the Layer-2 Frobenius energy and 98.52% for Layer 1. Temporal integration of presynaptic activity is a possible explanation for the concentration.
Left: Exact singular values of 64×64 Layer-2 eligibility Ē_j averaged across 12 CHB-MIT patients (328k windows; σ_7..σ_64 are algebraically zero). Right: Rank-1 fp16 SVD cuts weight RAM 32× at 0.976 cosine, yet binary spikes are still 9.4× smaller and exact.
Rank-1 fp16 SVD (S2_weight_svd_r1) tracks exact 3.98 MiB e-prop to four decimal places across the whole stream (0.75930 vs. 0.75935 ROC-AUC, 0.06836 vs. 0.06837 Brier, 0.1262 vs. 0.1261 Frobenius drift). Even on heavily shifted chb13 at η = 0.03, rank-1 SVD lifts ROC from 0.430 to 0.654, close to exact e-prop (0.654). Even so, saving the 48-byte binary spike train that generated E_bar_j beats rank-1 weight compression by 9.4× and keeps gradient fidelity at 1.000.
3. Auditing forecasting first (and why I moved to detection)
Before running the continual learning sweeps, I cloned the unmodified Future-Guided Learning repository (SkyeGunasekaran/FutureGuidedLearning, commit 5fa24ea) into a pinned Python 3.11 environment and ran all 12 case records using their exact README commands.
With α = 0.5 across 3 unseeded trials, the CNN-LSTM baseline averaged 0.546 (published: 0.581), while FGL distillation averaged 0.497 (published: 0.844). Sweeping all 11 values of α on the test set topped out at 0.588 on chb05 and 0.625 on chb21, with substantial variation across unseeded runs (chb13 ranged from 0.525 to 1.000 across 17 runs of identical code).
Comparing features and models on the same windows indicated that the evaluation protocol explained much of the performance difference. On FGL's curated windows (Protocol A), plain logistic regression on our 10 band-power features achieves 0.931 AUC (11/12 case records ≥ 0.9), our band-power SNN achieves 0.935, and our compact STFT SNN achieves 0.912 with 29× fewer parameters (0.32M vs. 9.34M) and 21× lower peak inference memory (2.1 vs. 44.7 MB) than FGL's CNN-LSTM (0.556 per-sample). Under chronological streaming (Protocol B: continuous 30-s grid, hard negatives 35 min to 3 h from seizures, censoring, validation thresholds), every EEG model dropped to 0.40–0.54 against 0.518 for a 5-parameter clock-only baseline.
I evaluated 27 seizures using rolling-origin splits and training-only normalization. Overall ROC-AUC was 0.577 for logistic regression, 0.553 for the SNN and 0.414 for the clock control. For the 24 seizures with negatives matched within ±1 hour, logistic regression reached 0.516 (95% clustered CI for the difference from clock: [−0.128, +0.342], p = 0.41) and the SNN reached 0.477 (CI [−0.179, +0.299], p = 0.64). A burst-normalized bias-only update reproduced the Brier improvement. I therefore evaluated delayed adaptation on seizure detection.
4. Continual seizure detection: depth vs. memory
For each target patient p, I trained a 3-seed population SNNForecaster on the other patients' ictal vs. interictal 30-second windows, mutually excluding chb01 and chb21 and fitting z-score stats strictly on the training patients. Dropping a population SNN cold onto a new patient's chronological 5-second stream (328,041 windows, 73 seizures) creates real distribution shift: frozen post-1st-seizure ROC averages 0.759, spanning from 0.375 (chb20), 0.399 (chb01), and 0.419 (chb13) all the way up to 0.980 (chb09).
chb13 Loss & ROCGenerated live in our Colab demo notebook. Training loss falls smoothly from 1.10 to 0.18 on the 11 training patients, while unseen chb13 loss climbs and cold-start ROC sits below 0.45. You can see right away why a frozen population SNN struggles on a shifted patient, and also why 2-bit delta spikes already generalize better cold than raw fp32.
During deployment, labels arrive 15–20 minutes late in 5-minute review bursts (60 windows per burst, backlog B_delay = 241, pos_w = 20). Every metric is scored strictly prequentially after each patient's first seizure feedback arrives (covering 61 unseen future seizures across 12 case records), with η selected strictly leave-one-patient-out.
Strictly prequential scores across the 61 unseen seizures after each patient's first confirmed seizure, averaged across 3 seeds with LOPO η selection (initial η grid up to 1e-2).
| Method | Space (Plastic) | Peak buffer payload | ROC | ΔROC vs Bias | PR | Brier | FPR@80% |
|---|---|---|---|---|---|---|---|
| A_frozen | Control (None) | 0 KiB | 0.7587 | −0.0018 | 0.2522 | 0.1477 | 37.0% |
| C0_bias_only | Control (1-param b) | 2.8 KiB | 0.7605 | 0.0000 | 0.2530 | 0.1194 | 37.0% |
| S1_input_full_bptt | Input (L1 + L2 + Head) | 1,019 KiB | 0.8198 | +0.0592* | 0.3023† | 0.0154 | 28.6% |
| S2_weight_eprop_exact | Weight (L2 + Head) | 3,979 KiB | 0.7593 | −0.0012 | 0.2176 | 0.0684 | 36.8% |
| S2_weight_svd_r1 | Weight (L2 + Head, r=1) | 123.8 KiB | 0.7593 | −0.0012 | 0.2175 | 0.0684 | 36.8% |
| S2_weight_block_L10 | Weight (L2 + Head, L=10) | 825.2 KiB | 0.7609 | +0.0003 | 0.2326 | 0.0965 | 36.3% |
| S2_weight_trace_unaligned | Weight (O(1) trace) | 33.0 KiB | 0.7641 | +0.0035 | 0.2590 | 0.1065 | 36.1% |
| S3_spike_l2_replay | Spike (L2 + Head, exact) | 13.2 KiB | 0.7596 | −0.0009 | 0.2173 | 0.0685 | 36.8% |
| S3_head_uint8 | Spike (Head, lossless) | 17.9 KiB | 0.7606 | +0.0001 | 0.2545 | 0.1221 | 36.8% |
| S3_head_block_L20 | Spike (Head, L=20) | 6.6 KiB | 0.7607 | +0.0002 | 0.2546 | 0.1215 | 36.7% |
fc1 (180→64), so full-net BPTT lifted 10 of 12 case records (+6.1% ROC, 9.6× lower Brier). Meanwhile, high-baseline chb09 (0.980 frozen) pulled LOPO PR selection down to a tiny η = 3e-4 for Layer-2 methods. Check Tab 4 of Figure 4 for shifted chb13 (seed 1) at η = 0.03: 13.2 KiB Spike L2 Replay jumps from 0.430 to 0.640 ROC (+0.201 over bias-only) and tracks 3.98 MiB e-prop (0.654) closely. That naturally raised the next question: what happens if we turn Layer 1's inputs into spikes too?
5. Retention under limited memory and noisy feedback
I evaluate two additional constraints: a buffer smaller than the feedback backlog (B < 240) and simulated feedback errors consisting of missed seizures and brief false-positive events.
To define the feedback gate g_t independently of FGL teacher logits, let c_j be the number of consecutive reported positive 5-second frames in the cluster around decision j inside the arrived batch. Real CHB-MIT seizures last 37 to 112 seconds (7 to 22 frames), while brief artifacts last 5 to 10 seconds (1 to 2 frames). I use the following gate:
Two lessons stood out. First, retention depends on how rare your target events are. On dense forecasting streams (Round 2), uniform reservoir beat FIFO, uncertainty, and a learned keep/drop model. On rare-event seizure detection (only 0.28% ictal frames), Top-Risk and Uncertainty beat both FIFO and reservoir in 0.88 to 1.75 KiB by holding onto rare seizure and boundary frames (pushing chb18 from 0.670 FIFO to 0.703 ROC and 0.043 to 0.077 PR in 0.88 KiB). Second, The noise experiments show that false alarms need not substantially degrade adaptation. Averaging updates across each review burst already absorbs 1.0 FA/h plus 50% missed seizures with under 0.001 ROC drift, and hard cluster gating (c_j ≥ 3) reduces the residual Brier error (0.1064 down to 0.1031) with no observed degradation under the tested missed-seizure condition.
6. End-to-end spike replay, recurrence and weight adaptation
Layer-2 spike replay freezes the input projection, whereas full-network input replay requires 0.995 MiB. The feedforward eligibility identity also does not extend directly to recurrent networks. I evaluate these constraints using three additional experiments with the same subject-grouped protocol, three seeds and 61 subsequent seizures, expanding the learning-rate grid to 3×10⁻².
- End-to-end multiply-free spike encoders. Replacing float32 EEG inputs with bit-packed causal spikes keeps all three layers plastic and permits multiply-free synaptic accumulation; membrane dynamics, gradients and weight updates still require arithmetic. 1-bit sign (
x_z > 0) takes 143 B/dec = 33.7 KiB at 15 min (442× smaller than 14.88 MiB full-net e-prop). 2-bit bipolar ON/OFF (x_z > 0.5/< −0.5) and 2-bit causal delta+level (x_z > 0.75orΔx_z > 0.5) take 278 B/dec = 65.4 KiB (227× smaller than theoretical full-network e-prop). - Recurrent LIF (
snn.RLeaky, 64×64 lateral recurrence). Once you add lateral weightsV_rec, local recurrent e-prop has to buffer two 64×64 matrices (33,292 B/dec = 7.84 MiB at 15 min, 25.4 MiB at 60 min) and becomes approximate (cos = 0.9955vs. exact recurrent BPTT). Binary Layer-1 spike replay stays at 56 B/dec (13.2 KiB) and delivers the exact current-weight recurrent BPTT gradient under the stated assumptions at 594.5× less RAM. - Layer-1 weight-space geometry & Spiking LoRA. I measured exact 64×180 Layer-1 eligibility SVD (98.5% energy in σ_1), cumulative patient weight shifts
ΔW_1 = W_1^(p) − W_1^pop, and online rank-r Spiking LoRA (r = 1, 2, 4).
Same 12-case subject-grouped LOPO protocol (chb01 & chb21 mutually excluded, 3 seeds, strict LOPO η up to 3e-2, 61 unseen post-1st-seizure events). Bit-exact pack/unpack roundtrips are checked on every patient.
snn.RLeaky) 12-Patient Detection & Measured e-prop Approximation GapLeft: 12-case RLeaky continual detection scores; 65.4 KiB 2-bit bipolar E2E (0.836 ROC, p=0.027) closely tracks 0.995 MiB fp32 BPTT (0.842 ROC). Right: Across all 36 patient-seed runs, local recurrent e-prop (7.84 MiB) falls short of exact recurrent BPTT (mean ictal cosine 0.9952, min 0.991), while 13.2 KiB binary spike replay achieves a cosine of 1.000.
| Architecture & Spike Front-End | Peak buffer payload | vs. Full e-prop | ROC | PR | Brier | FPR@80% | ΔROC (p) |
|---|---|---|---|---|---|---|---|
FF: fp32 Frozen / Bias-Only |
0 / 2.8 KiB | — | 0.767 / 0.768 | 0.292 / 0.290 | 0.113 / 0.093 | 35.5% | baseline |
FF: fp32 Full-Net BPTT |
1,019 KiB | 14.6× | 0.8558 | 0.3836 | 0.0116 | 23.7% | +0.088 (.005) |
FF: 1bit_sign E2E (add/sub synapses) |
33.7 KiB | 442× | 0.8419 | 0.2259 | 0.0142 | 24.3% | +0.035 (PR .034) |
FF: 2bit_delta E2E (add/sub synapses) |
65.4 KiB | 227× | 0.8493 | 0.3160 | 0.0143 | 24.9% | +0.053 (.042) |
FF: 2bit_bipolar E2E (add/sub synapses) |
65.4 KiB | 227× | 0.8409 | 0.2914 | 0.0160 | 26.8% | +0.081 (.016) |
FF: Spiking LoRA r=2 (2bit / fp32) |
65.4 / 1,019 KiB | — | 0.795 / 0.809 | 0.184 / 0.275 | 0.020 / 0.020 | 34.1 / 31.9% | +0.035 / +0.041 |
RLeaky: fp32 Full-Net BPTT |
1,019 KiB | 18.4× | 0.8417 | 0.3706 | 0.0143 | 27.0% | +0.068 (.012) |
RLeaky: 2bit_bipolar E2E (add/sub synapses) |
65.4 KiB | 287× | 0.8363 | 0.2715 | 0.0183 | 26.7% | +0.070 (.027) |
η = 3e-3, each patient's cumulative Layer-1 shift ΔW_1 puts 82–92% of its energy in rank 1 (98–99.6% in rank 4). Yet across different patients, those shifts are nearly perpendicular: mean off-diagonal cosine is 0.004 on both 2bit_delta and fp32. I observed that across all four encoder configurations, the #1 highest cosine pair out of all 66 pairs was chb01 ↔ chb21, the same patient recorded 1.5 years apart (0.631 on 2-bit delta vs. 0.357 for the #2 pair; 0.512 on fp32; 0.546 on 1-bit sign). chb01 and chb21 share the same 10-patient LOPO initialization because we mutually excluded them, though the other 65 pairs also share about 90% of their training patients and still average 0.004. This geometry may help explain why Online Spiking LoRA (r=1,2,4) lagged at 0.795: a frozen random A basis simply cannot line up fast enough with each patient's orthogonal focal channels.
Limitations
This study is a retrospective replay on 12 pediatric CHB-MIT recordings (11 unique people from one hospital), and subject-level grouping should also be verified for hyperparameter selection and statistical tests. Checking multi-center datasets like TUSZ or Siena is a direction for further validation. All memory numbers are exact packed bytes and parameter counts, while the multiply-free synaptic accumulation claim is analytical; total compute and energy on physical hardware were not measured. For the recurrent layer, I benchmarked against local recurrent e-prop (O(N²), 7.84 MiB at D = 15 min) rather than full RTRL (O(N³), which would require hundreds of megabytes across 241 pending windows and is infeasible on wearable SRAM); binary Layer-1 spike replay (O(N·T) at 13.2 KiB) recomputes the current-weight recurrent BPTT gradient for the retained spikes, using 594.5× less buffer payload than local recurrent e-prop. Full RTRL was not benchmarked. Finally, my recurrent e-prop approximation check (0.9955 cosine) used 6-step windows with detached reset; longer windows may widen the approximation gap; this was not tested.
7. Core code
The project logs report 40 passing automated unit tests (pytest tests -q). Here are the three main primitives behind the experiments.
A. Exact Layer-2 e-prop & fast T×T QR+SVD
def eligibility_svd_fast(s1, psi, beta2, rank):
"""Exact rank-r SVD of E_bar = (1/T) psi.T @ Eps via T x T QR+SVD (rank <= T)."""
T, n_in = s1.shape
eps = np.zeros((T, n_in), dtype=np.float64)
eps_b = np.zeros(T, dtype=np.float64)
cur, cb = np.zeros(n_in), 0.0
for t in range(T):
cur = beta2 * cur + s1[t]
cb = beta2 * cb + 1.0
eps[t], eps_b[t] = cur, cb
Eb = (psi.T @ eps_b) / T
# Thin QR reduces 64x64 SVD to an exact 6x6 SVD (~20x faster, error < 1e-11)
Q1, R1 = np.linalg.qr(psi.T, mode="reduced")
Q2, R2 = np.linalg.qr(eps.T, mode="reduced")
u_m, s_all, vt_m = np.linalg.svd((R1 @ R2.T) / T, full_matrices=False)
r = min(rank, len(s_all))
return Q1 @ u_m[:, :r], s_all[:r], vt_m[:r, :] @ Q2.T, Eb, s_all
B. 56-byte binary spike replay with burst normalisation
# At decision time t_i: store only bit-packed binary Layer-1 spikes (48 B + 8 B ts)
store[i] = np.packbits(S1[i])
# At arrival time r_j <= t_i: unpack spikes & regenerate exact current-weight gradient
for j in arrivals:
packed = store.pop(j, None)
if packed is None or not usable[j]:
continue
s1_j = np.unpackbits(packed)[: T * n_in].reshape(T, n_in).astype(np.float64)
_, psi_j, hj = layer2(s1_j, W2, b2, beta2)
E_j, Eb_j = eligibility(s1_j, psi_j, beta2)
pj = sigmoid(hj @ w + b)
err = float(g[j]) * (pos_w if y[j] == 1 else 1.0) * (pj - y[j])
gw += err * hj; gb += err
gW2 += err * (w[:, None] * E_j); gb2 += err * (w * Eb_j)
n_eff += 1
# Burst normalisation: average simultaneous arrivals to prevent ~60-label blowup
if n_eff > 0 and burst_norm:
gw /= n_eff; gb /= n_eff; gW2 /= n_eff; gb2 /= n_eff
C. Causal 2-bit delta spike encoder (add/sub synapses, 65.4 KiB)
def encode_spikes_2bit_delta(X_norm, thr_lvl=0.75, thr_del=0.5):
"""Strictly causal 2-bit ON/OFF level + temporal-delta encoder ((-1, 0, 1))."""
dx = np.zeros_like(X_norm, dtype=np.float32)
dx[:, 1:, :] = X_norm[:, 1:, :] - X_norm[:, :-1, :]
on = ((X_norm > thr_lvl) | (dx > thr_del)).astype(np.uint8)
off = ((X_norm < -thr_lvl) | (dx < -thr_del)).astype(np.uint8)
both = (on == 1) & (off == 1)
on = np.where(both, (X_norm >= 0).astype(np.uint8), on)
off = np.where(both, (X_norm < 0).astype(np.uint8), off)
return on, off # Packed into 270 B + 8 B timestamp = 278 B/decision (65.4 KiB @ 15m)
Interactive Live Demo Notebook
References
- Gunasekaran, S. et al. (2025). Future-Guided Learning for Seizure Prediction. Nature Communications.
- Bellec, G., Scherr, F., Subramoney, A., Hajek, E., Salaj, D., Legenstein, R., & Maass, W. (2020). A solution to the learning dilemma for recurrent networks of spiking neurons (e-prop). Nature Communications.
- Eshraghian, J. K., Ward, M., Neftci, E., Wang, X., Lenz, G., Dwivedi, G., Bennamoun, M., Jeong, D. S., & Lu, W. D. (2023). Training Spiking Neural Networks Using Lessons From Deep Learning (snnTorch). Proceedings of the IEEE.
- Shoeb, A. H. (2009). Application of Machine Learning to Epileptic Seizure Onset Detection and Treatment (CHB-MIT Scalp EEG Database). MIT PhD Thesis / PhysioNet.