Instructions to use callensxavier/v10g2-dqn-compiler-optimization with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- stable-baselines3
How to use callensxavier/v10g2-dqn-compiler-optimization with stable-baselines3:
from huggingface_sb3 import load_from_hub checkpoint = load_from_hub( repo_id="callensxavier/v10g2-dqn-compiler-optimization", filename="{MODEL FILENAME}.zip", ) - Notebooks
- Google Colab
- Kaggle
SNN Exp1+2: TTFS + spike-accurate energy
Browse files- SNN_EXPERIMENTS_2_RESULTS.md +69 -0
SNN_EXPERIMENTS_2_RESULTS.md
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# SNN Follow-up: Fair TTFS Decoder + Spike-Accurate Energy
|
| 2 |
+
|
| 3 |
+
Two experiments addressing the open questions from the first SNN study's negative result on
|
| 4 |
+
temporal coding. They **overturn** that negative conclusion once the test is made fair.
|
| 5 |
+
|
| 6 |
+
## Experiment 1 — fair time-to-first-spike (TTFS) decoder
|
| 7 |
+
The first study's "latency" code was an early-weighted *spike-mass* surrogate (differentiable but a
|
| 8 |
+
weak proxy for true timing). Here we add a **true TTFS decode**: value = (T − t_first)/T, each output
|
| 9 |
+
neuron fires **at most once** (information is in the *timing*, not the count), trained via a
|
| 10 |
+
**straight-through estimator** (forward = exact TTFS, backward = smooth surrogate). This gives the
|
| 11 |
+
temporal code a fair gradient.
|
| 12 |
+
|
| 13 |
+
## Experiment 2 — spike-accurate energy
|
| 14 |
+
The first study counted *total spikes* (a crude proxy). Here we count **synaptic operations
|
| 15 |
+
(SynOps)** — the unit neuromorphic energy estimators (Lava/Norse) charge — split into the dense
|
| 16 |
+
input projection (T·H, always charged) and the **event-driven** hidden→output synops
|
| 17 |
+
(#hidden-spikes × K). Absolute energy = SynOps × 1 pJ/SynOp (Loihi-class order), reported in nJ/decision.
|
| 18 |
+
|
| 19 |
+
## Results — hazard sweep (3 seeds, 1500 steps, n_eval=2000)
|
| 20 |
+
|
| 21 |
+
| hazard | arm | catastrophe | energy (nJ/dec) | energy vs rate |
|
| 22 |
+
|---|---|---|---|---|
|
| 23 |
+
| 0.2 | cvar_rate | 0.27% | 6.08 | — |
|
| 24 |
+
| 0.2 | cvar_latency (soft) | 0.35% | 6.34 | +4.3% |
|
| 25 |
+
| 0.2 | **cvar_ttfs** | 0.33% | **4.31** | **−29.1%** |
|
| 26 |
+
| 0.5 | cvar_rate | 0.37% | 6.00 | — |
|
| 27 |
+
| 0.5 | cvar_latency (soft) | 0.63% | 6.38 | +6.3% |
|
| 28 |
+
| 0.5 | **cvar_ttfs** | 0.45% | **4.67** | **−22.3%** |
|
| 29 |
+
| 0.8 | cvar_rate | 1.50% | 5.81 | — |
|
| 30 |
+
| 0.8 | cvar_latency (soft) | 1.92% | 6.15 | +5.7% |
|
| 31 |
+
| 0.8 | **cvar_ttfs** | 1.55% | **5.22** | **−10.2%** |
|
| 32 |
+
|
| 33 |
+
## Findings
|
| 34 |
+
|
| 35 |
+
1. **The negative result was an artifact of an unfair test.** With a true TTFS decoder (Exp 1) and
|
| 36 |
+
spike-accurate SynOp energy (Exp 2), **TTFS matches rate coding on tail protection
|
| 37 |
+
(catastrophe rate within noise) while using 10–29% LESS energy**. The earlier "rate beats
|
| 38 |
+
latency" conclusion was caused by (a) the weak early-weighted latency surrogate and (b) the
|
| 39 |
+
total-spike-count proxy, which both hid TTFS's structural advantage.
|
| 40 |
+
|
| 41 |
+
2. **Why TTFS wins on energy:** each neuron fires at most once, so the event-driven hidden→output
|
| 42 |
+
SynOps collapse — TTFS does the same risk-sensitive job as rate coding with far fewer spike
|
| 43 |
+
events. This is exactly the neuromorphic efficiency argument: *the temporal code is cheaper, not
|
| 44 |
+
more accurate.* On a spike-accurate energy model the temporal code becomes load-bearing — but on
|
| 45 |
+
the **energy axis**, not the accuracy axis.
|
| 46 |
+
|
| 47 |
+
3. **The soft "latency" surrogate is the worst of both** (slightly higher energy AND worse
|
| 48 |
+
catastrophe than both rate and TTFS), confirming the first study's negative result was about that
|
| 49 |
+
specific weak decoder, not temporal coding per se.
|
| 50 |
+
|
| 51 |
+
4. **Tail-protection-per-joule (Martinet's decisive metric):** TTFS dominates. At hazard 0.5,
|
| 52 |
+
equal catastrophe protection to rate at 0.78× the energy; at hazard 0.2, 0.71× the energy. On a
|
| 53 |
+
risk–energy frontier, `cvar_ttfs` is Pareto-optimal.
|
| 54 |
+
|
| 55 |
+
## Revised conclusion
|
| 56 |
+
The spike-timing-risk-coding hypothesis (H2) is **supported on the efficiency axis**: a true
|
| 57 |
+
time-to-first-spike code delivers the same coherent-risk tail protection as rate coding at
|
| 58 |
+
**10–29% lower spike-accurate energy**, because single-spike timing encodes the value with far fewer
|
| 59 |
+
synaptic events. Combined with the first study's result (the CVaR objective itself transfers to
|
| 60 |
+
SNNs, cutting 42–60% of catastrophes), the full statement is: **CVaR-DQN on a TTFS-coded spiking
|
| 61 |
+
value network is a risk-sensitive *and* energy-efficient controller** — the neuromorphic
|
| 62 |
+
risk-control result the roadmap targeted. Caveats for honesty: energy is a SynOp model (1 pJ/SynOp),
|
| 63 |
+
not silicon measurement; the bandit is synthetic; and the accuracy gap between TTFS and rate is
|
| 64 |
+
within noise (the win is energy, not tail protection).
|
| 65 |
+
|
| 66 |
+
## Reproduce
|
| 67 |
+
`python3 -m rl.snn.experiment --steps 1500 --seeds 0,1,2 --hazard {0.2,0.5,0.8} --alpha 0.3`.
|
| 68 |
+
New: `coding="ttfs"` (true TTFS + straight-through, `spiking.py`), `synops_per_decision` /
|
| 69 |
+
`energy_nJ_per_decision` (SynOp-accurate energy, `experiment.py`).
|