Why SNNs for anomaly detection
Anomaly detection on edge devices has a hard constraint: the device runs continuously, on battery, without offloading data. An SNN has a key operational property: in normal conditions, the input is nominal, the membrane potentials stay near baseline, and the network fires sparsely. Power consumption is proportional to spike count — which is low. When a fault occurs, the signal deviates, more spikes are generated, and the anomaly is detected. This is the inverse of the problem on a GPU, where “computing nothing” costs the same as computing something.Problem setup
A 128-channel sensor array monitors an industrial system (motor drive, airframe, reactor coolant loop). Normal operation is a compact, approximately Gaussian region of the state space. Three fault modes perturb disjoint sensor clusters in characteristic patterns.
Training uses a 50/50 balance between normal and anomaly samples — standard practice for learning discriminative fault features without majority-class collapse. Testing uses a 15% anomaly rate, matching a realistic operational distribution.
Architecture
Sensor readings are normalised withtanh(x) and rate-encoded over T = 100 timesteps. The SNN classifies the encoded spike train:
Encoding
Sensor values are normalised to[0, 1] using tanh, then rate-encoded:
tanh squash is critical: Fault C suppresses channels to −5σ, which maps to near-zero firing rate (≈ 0.00003) — clearly distinct from the normal-class mean of ≈ 0.50. Plain clamp-to-zero would map to 0.50 and be undetectable.
Training
Running the template
Results
Committed floor: AUROC ≥ 0.90
The floor is cleared by epoch 2. The model achieves near-perfect separation on the synthetic distribution — each fault mode shifts distinct sensor clusters far enough from the normal mean that the Dense weights quickly learn to isolate them.
For real industrial datasets (CWRU bearing, MIMII, SKAB), expect AUROC in the 0.90–0.99 range depending on fault severity and class balance.
Compile and run
templates/anomaly-detection/samples/: one normal, one Fault A, one Fault B.
Adapting to real datasets
-
Replace the data generator with your data loader. Ensure sensor values are passed through
tanhnormalisation beforeencoders.rate. -
Class imbalance > 90/10: balance the training set (oversample anomaly) or add class weights:
- Tune τ_mem to sensor periodicity — for vibration data at 12 kHz, T should cover at least one full period.
- Real-world references:
Why this is a canonical neuromorphic use case
- Always-on, low power: the SNN is quiet when the system is healthy — only faults generate elevated spike activity
- Event-driven: the model can be clocked at sensor rate rather than a fixed compute cycle
- On-device decision: no telemetry or cloud round-trip needed
- Calibratable: the decision threshold is a scalar, adjustable in production without retraining