Skip to main content

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 with tanh(x) and rate-encoded over T = 100 timesteps. The SNN classifies the encoded spike train:
Two output neurons: class 0 (normal) and class 1 (anomaly). The anomaly score used for AUROC is the mean firing rate of the anomaly output neuron over T timesteps.
Why τ_mem = 10 ms? Sensor readings are largely non-periodic — a short time constant keeps each timestep’s contribution independent, preventing the membrane from integrating irrelevant temporal context across T = 100 steps.

Encoding

Sensor values are normalised to [0, 1] using tanh, then rate-encoded:
The 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

No class weighting is needed when training on balanced data. The cosine LR schedule stabilises convergence in the final epochs.

Running the template

No external dataset download required. Training for 50 epochs on CPU takes roughly 5–8 minutes.

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

Three labelled samples are bundled in templates/anomaly-detection/samples/: one normal, one Fault A, one Fault B.

Adapting to real datasets

  1. Replace the data generator with your data loader. Ensure sensor values are passed through tanh normalisation before encoders.rate.
  2. Class imbalance > 90/10: balance the training set (oversample anomaly) or add class weights:
  3. Tune τ_mem to sensor periodicity — for vibration data at 12 kHz, T should cover at least one full period.
  4. 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
At ~50% normal-class firing rate and Dense(128 → 256) as the dominant cost layer, the SNN consumes roughly 2× fewer synaptic operations than an equivalent frame-based model when the system is in a healthy state.