YAML Metadata Warning:empty or missing yaml metadata in repo card

Check out the documentation for more information.

SH-SNN: Self-Healing Spiking Neural Networks

Diagnosis-aware continual recovery for Spiking Neural Networks under dynamic failures.

This repository contains the experimental implementation of SH-SNN, a proof-of-concept framework for self-healing Spiking Neural Networks (SNNs) in dynamic edge environments.

SH-SNN separates the adaptation process into three stages:

Monitoring β†’ Failure Diagnosis β†’ Cause-Specific Recovery

The current implementation studies four deployment failures:

  • Event/sensor noise
  • Spatial distribution shift
  • Class imbalance
  • New-class arrival

It also evaluates continual-learning strategies including:

  • Naive sequential learning
  • Elastic Weight Consolidation (EWC)
  • Learning without Forgetting (LwF)
  • Experience Replay

Proposed SH-SNN Pipeline

Event Stream
     ↓
LIF Spiking Neural Network
     ↓
Label-Free Monitoring
     ↓
Failure Detection
     ↓
Causal Root-Cause Attribution
     ↓
Recovery Policy Selection
     ↓
Continual Adaptation
     ↓
Updated SNN

The recovery controller selects an adaptation strategy according to the diagnosed failure:

Failure Recovery Strategy
Event noise Denoising + replay
Spatial shift Replay-based adaptation
Class imbalance Class-weighted replay
New-class arrival Class-incremental replay

Current Experimental Dataset

The current proof-of-concept experiments use N-MNIST.

For the operational model:

  • Classes 0–7 are treated as known classes.
  • Classes 8–9 are held out as novel classes.

The continual-learning sequence is:

Task 1: {0, 1}
Task 2: {2, 3}
Task 3: {4, 5}
Task 4: {6, 7}
Task 5: {8, 9}

SNN Architecture

The classifier is a convolutional Leaky Integrate-and-Fire (LIF) SNN implemented with snnTorch.

Input Event Frames
       ↓
Conv2D
       ↓
Batch Normalization
       ↓
Average Pooling
       ↓
LIF Neurons
       ↓
Conv2D
       ↓
Batch Normalization
       ↓
Average Pooling
       ↓
LIF Neurons
       ↓
Adaptive Average Pooling
       ↓
Linear Classifier

Input event tensors are represented as:

[Batch, Time, Polarity, Height, Width]

Controlled Failure Injection

1. Event Noise

Low:     0.03
Medium:  0.07
High:    0.15

2. Spatial Shift

Low:     2 pixels
Medium:  4 pixels
High:    6 pixels

3. Class Imbalance

Minority-class retention:

Low:     50%
Medium:  25%
High:    10%

4. New-Class Arrival

Novel-class proportion:

Low:     10%
Medium:  25%
High:    50%

Label-Free Monitoring

The monitoring module extracts:

  • Prediction entropy
  • Prediction confidence
  • Predicted-class imbalance
  • Internal spike rate
  • Input event activity
  • Spatial event centroid
  • Latent embedding deviation

These signals are standardized relative to clean validation windows to produce a monitoring score.


Failure Detection

The implementation evaluates ADWIN as a streaming change detector.

Current limitation:
In the present short N-MNIST pilot streams, the monitoring score changes clearly under major failures such as noise and spatial shift, but the evaluated ADWIN configuration does not reliably trigger.

Therefore, this repository does not claim fully autonomous end-to-end failure detection.


Causal Failure Diagnosis

Root-cause attribution is implemented using DoWhy-GCM.

The diagnostic proxies are:

Activity deviation       β†’ Noise
Centroid deviation       β†’ Spatial shift
Prediction imbalance     β†’ Class imbalance
Embedding deviation      β†’ New-class arrival

The causal graph is manually defined from the controlled experimental setting.

The implementation does not claim causal-structure discovery from observational data.

A Random Forest classifier is also evaluated as a non-causal diagnostic baseline.


Self-Healing Recovery

The recovery experiment compares:

No Recovery
Naive Fine-Tuning
Fixed Replay
Fixed EWC
SH-SNN with Predicted Diagnosis
SH-SNN with Oracle Diagnosis

The oracle version uses the known controlled failure label and serves as an upper bound for recovery when diagnosis is correct.


Recovery Metric

For failures that reduce accuracy, the Accuracy Recovery Ratio (ARR) is:

              A_healed - A_failure
ARR = -----------------------------------
             A_pre - A_failure

where:

A_pre      = accuracy before failure
A_failure  = accuracy after failure
A_healed   = accuracy after recovery

ARR is not interpreted when:

A_failure >= A_pre

This is especially important for class imbalance, where raw accuracy may increase because majority classes dominate the test distribution.

For imbalance experiments, macro-F1 and balanced accuracy are more informative.


Current Pilot Results

These are N-MNIST SMOKE / proof-of-concept results and should not be interpreted as state-of-the-art benchmark results.

Baseline SNN

Accuracy:              76.00%
Balanced Accuracy:     75.20%
Macro-F1:              74.25%
Trainable Parameters:  10,122
Internal Spike Rate:   ~0.204

Operational Known-Class Model

Accuracy:   82.17%
Macro-F1:   81.47%

Failure Sensitivity

Failure Low Medium High
Noise 31.42% 16.96% 12.84%
Spatial Shift 71.07% 38.65% 18.70%
New-Class Arrival 73.06% 65.51% 58.88%

For class imbalance, raw accuracy is misleading; macro-F1 is emphasized instead.

Causal Diagnosis

Condition-level causal diagnosis accuracy: 58.3%

Correct diagnoses:

Noise:          3 / 3
Spatial shift:  3 / 3

The causal model was less effective for:

Class imbalance
New-class arrival

A Random Forest diagnostic baseline achieved approximately:

Accuracy:   73.8%
Macro-F1:   71.5%

Recovery–Retention Example

Under medium event noise:

Clean accuracy:    82.17%
Failure accuracy:  16.46%

Naive fine-tuning:

Healed accuracy:   79.30%
Clean retention:   15.34%

Predicted SH-SNN:

Healed accuracy:   73.82%
ARR:               0.873
Clean retention:   75.06%

This demonstrates an important motivation of the framework:

High immediate recovery does not necessarily mean safe recovery. A useful self-healing method should restore performance while preserving previously learned knowledge.


Repository Structure

Recommended structure:

SH-SNN/
β”‚
β”œβ”€β”€ README.md
β”œβ”€β”€ LICENSE
β”œβ”€β”€ requirements.txt
β”œβ”€β”€ .gitignore
β”‚
β”œβ”€β”€ notebooks/
β”‚   └── SH_SNN_Paper1_Experiments.ipynb
β”‚
β”œβ”€β”€ figures/
β”‚   β”œβ”€β”€ fig_failure_degradation.png
β”‚   β”œβ”€β”€ fig_causal_confusion.png
β”‚   └── fig_recovery_retention.png
β”‚
β”œβ”€β”€ results/
β”‚   └── nmnist_pilot/
β”‚
└── paper/
    β”œβ”€β”€ main.tex
    └── references.bib

The project can initially be uploaded as a single Colab notebook. The code can later be modularized into separate Python files.


Environment

The latest tested Google Colab environment was:

Python:           3.13.15
NumPy:            2.5.1
SciPy:            1.16.3
Pandas:           2.2.3
scikit-learn:     1.9.0
PyTorch:          2.11.0+cu128
Tonic:            1.6.0
snnTorch:         1.0.0
River:            0.25.0
DoWhy:            0.14
GPU:              NVIDIA Tesla T4

Installation

A Google Colab GPU runtime is recommended.

Install the required SNN and streaming packages:

pip install tonic==1.6.0
pip install snntorch==1.0.0
pip install river==0.25.0

For causal attribution:

pip install dowhy==0.14

The notebook uses the PyTorch/CUDA environment supplied by Google Colab.


Running the Code

Quick Pipeline Validation

RUN_MODE = "SMOKE"
DATASET_NAME = "NMNIST"
SEED = 42

This mode uses smaller datasets and fewer epochs to verify that the complete experimental pipeline executes correctly.

Full Experimental Mode

RUN_MODE = "PAPER"
DATASET_NAME = "CIFAR10DVS"
SEED = 42

or:

RUN_MODE = "PAPER"
DATASET_NAME = "DVSGESTURE"
SEED = 42

For stronger statistical evaluation, repeat with multiple seeds:

42
123
2026

and report:

mean Β± standard deviation

Generated Outputs

The notebook generates outputs including:

E1_baseline_metrics.csv
E1_baseline_history.csv

E2_continual_summary.csv
E2_naive_accuracy_matrix.csv
E2_ewc_accuracy_matrix.csv
E2_lwf_accuracy_matrix.csv
E2_replay_accuracy_matrix.csv

E3_failure_degradation.csv

E4_ADWIN_detection.csv
E4_clean_monitor_windows.csv

E5_causal_root_cause.csv

E6_self_healing_medium.csv

E7_severity_analysis.csv
E7_ablation_summary.csv

experiment_config.json
paper_summary.json

Figures and result tables are also generated automatically.


Reproducibility

The implementation controls:

  • Python random seed
  • NumPy random seed
  • PyTorch random seed
  • CUDA random seed
  • deterministic CuDNN behavior where possible

Seed-specific outputs are stored separately.

Example:

results/
└── CIFAR10DVS/
    └── PAPER/
        β”œβ”€β”€ seed_42/
        β”œβ”€β”€ seed_123/
        └── seed_2026/

Limitations

The current implementation has the following limitations:

  1. N-MNIST is currently used as a proof-of-concept dataset.
  2. The reported smoke results use reduced dataset sizes and training schedules.
  3. ADWIN does not reliably trigger in the current short monitoring streams.
  4. Causal attribution distinguishes noise and spatial shift more effectively than imbalance and new-class arrival.
  5. Recovery currently assumes labeled adaptation samples.
  6. GPU latency and spike-rate measurements are not direct measurements of neuromorphic energy consumption.
  7. Larger datasets and multiple-seed validation are required before making broad performance claims.

Future Work

Planned extensions include:

  • CIFAR10-DVS experiments
  • DVS128 Gesture experiments
  • Multiple-seed evaluation
  • Improved streaming change detection
  • Better novelty representations
  • Improved imbalance diagnostics
  • Label-efficient recovery
  • Unsupervised recovery
  • Resource-aware adaptation
  • Neuromorphic hardware deployment
  • Direct energy-consumption measurements

Associated Paper

Working title:

SH-SNN: Causal Attribution-Guided Continual Recovery for Spiking Neural Networks Under Dynamic Failures

The manuscript evaluates SH-SNN as a proof-of-concept framework for diagnosis-aware continual recovery.


Citation

If you use this repository, please cite the associated paper once the final bibliographic information becomes available.

@inproceedings{shsnn2026,
  title     = {SH-SNN: Causal Attribution-Guided Continual Recovery
               for Spiking Neural Networks Under Dynamic Failures},
  author    = {Author Name(s)},
  booktitle = {Conference Name},
  year      = {2026}
}

Replace the placeholder author and conference information after publication.


License

This repository is intended for academic research.

Before public release, add an appropriate open-source license such as the MIT License, subject to your institution's intellectual-property requirements.


Disclaimer

This repository contains experimental research code.

The current N-MNIST results represent a proof-of-concept evaluation and should not be interpreted as production-level autonomous self-healing performance, state-of-the-art benchmark results, or direct evidence of neuromorphic energy efficiency.

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support