Skip to content

Spiking neural network IDS achieving 73.4% accuracy on NSL-KDD at 1,620 pJ per inference. Novel spike count classification solves SNN class collapse, detecting all five attack categories including U2R (69.2% recall from 52 samples). Targeting neuromorphic hardware deployment in power-constrained tactical environments.

Notifications You must be signed in to change notification settings

SephDavis/NeuroIDS

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

12 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

NeuroIDS: Neuromorphic Intrusion Detection System

License: MIT Python 3.8+ DOI

Energy-efficient network intrusion detection using spiking neural networks for tactical and edge deployment.

NeuroIDS achieves 73.4% accuracy on the NSL-KDD benchmark while consuming only 1,620 pJ per inferenceβ€”approximately 10,000x more energy-efficient than equivalent deep learning approaches. Unlike previous SNN-based IDS implementations that failed on minority attack classes, NeuroIDS successfully detects all five traffic categories including the challenging R2L and U2R attacks.

NeuroIDS Architecture

🎯 Key Results

Attack Category Recall Support Notes
Normal 87.9% 9,711 Low false positive rate
DoS 67.4% 7,458 Denial of Service attacks
Probe 82.9% 2,421 Reconnaissance/scanning
R2L 33.7% 2,887 Remote to Local attacks
U2R 69.2% 67 User to Root privilege escalation

Overall Accuracy: 73.4% | Energy: 1,620 pJ/inference | All 5 classes detected

Comparison with Baseline SNN

Metric Baseline SNN NeuroIDS v4
Accuracy 63.0% 73.4%
Classes Detected 2/5 5/5
Probe Recall 0% 82.9%
R2L Recall 0% 33.7%
U2R Recall 0% 69.2%

Related Papers

This is the first paper in the NeuroIDS series:

Paper Description Link
NeuroIDS Terrestrial SNN-based IDS (this repo) DOI: 10.13140/RG.2.2.23827.13604
NeuroIDS-Sat Space-adapted variant for CubeSat constellations with TMR radiation tolerance DOI: 10.13140/RG.2.2.16893.42724
NeuroIDS-Adversarial Adversarial robustness analysis and defensive hardening GitHub

πŸš€ Quick Start

Installation

# Clone the repository
git clone https://github.com/SephDavis/NeuroIDS.git
cd NeuroIDS

# Install dependencies
pip install -r requirements.txt

Download NSL-KDD Dataset

  1. Download from UNB NSL-KDD
  2. Place KDDTrain+.txt and KDDTest+.txt in data/NSL-KDD/

Train the Model

python examples/train_nslkdd.py

Use Pre-trained Model

from src.neuroids_v4 import NeuroIDS

# Load pre-trained model
model = NeuroIDS.load('models/pretrained/nslkdd_model_v4.pkl')

# Predict on new data (normalized features, shape: [n_samples, 41])
predictions = model.predict(X_test)

# Get probabilities
probabilities = model.predict_proba(X_test)

# Evaluate
metrics = model.evaluate(X_test, y_test)
print(f"Accuracy: {metrics['accuracy']:.4f}")

πŸ“ Project Structure

NeuroIDS/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ neuroids_v4.py        # Main SNN implementation (USE THIS)
β”‚   β”œβ”€β”€ data_augmentation.py  # SMOTE and class balancing
β”‚   β”œβ”€β”€ data.py               # Data loading utilities
β”‚   β”œβ”€β”€ neurons.py            # LIF neuron models
β”‚   β”œβ”€β”€ encoders.py           # Spike encoding schemes
β”‚   β”œβ”€β”€ layers.py             # SNN layer implementations
β”‚   └── utils.py              # Helper functions
β”œβ”€β”€ examples/
β”‚   β”œβ”€β”€ train_nslkdd.py       # Full training script
β”‚   β”œβ”€β”€ quick_start.py        # Basic usage example
β”‚   └── energy_analysis.py    # Energy efficiency evaluation
β”œβ”€β”€ models/
β”‚   └── pretrained/
β”‚       └── nslkdd_model_v4.pkl
β”œβ”€β”€ data/
β”‚   └── NSL-KDD/              # Place dataset here
β”œβ”€β”€ docs/
β”‚   └── NeuroIDS_Paper.pdf    # IEEE paper
β”œβ”€β”€ tests/
β”‚   └── test_network.py
β”œβ”€β”€ requirements.txt
└── README.md

🧠 How It Works

Architecture

NeuroIDS uses a feedforward spiking neural network with Leaky Integrate-and-Fire (LIF) neurons:

Input (41 features) β†’ Spike Encoding β†’ Hidden Layer (128 LIF) β†’ Hidden Layer (64 LIF) β†’ Output (5 classes)

Key Innovations

  1. Spike Count-Based Classification: Instead of backpropagating through non-differentiable spikes, we use accumulated spike counts as continuous features for the output layer. This enables stable gradient-based learning.

  2. Adaptive Class Scaling: Dynamically adjusts class weights during training to prevent collapse to majority classesβ€”critical for detecting rare attacks like U2R (only 52 training samples).

  3. Balanced Sampling: Undersamples majority classes and oversamples minority classes to create balanced training batches without expensive synthetic data generation.

LIF Neuron Dynamics

V(t+1) = V_rest + (V(t) - V_rest) Γ— exp(-Ξ”t/Ο„_m) + R_m Γ— I(t)

If V(t) β‰₯ V_thresh: spike and reset to V_reset
Parameter Value
Membrane time constant (Ο„_m) 15.0 ms
Threshold (V_thresh) 0.5
Reset potential (V_reset) 0.0
Refractory period 2.0 ms

⚑ Energy Efficiency

NeuroIDS is designed for deployment on neuromorphic hardware where energy efficiency is critical:

Metric Value
Average spikes per inference 810
Energy per spike (neuromorphic HW) ~2 pJ
Total SNN energy 1,620 pJ
Equivalent ANN energy ~68.8 mJ
Efficiency gain ~10,000-42,000Γ—

At 1,620 pJ per inference, NeuroIDS can process ~600,000 samples/second/milliwatt, enabling:

  • Battery-powered edge deployment
  • Always-on monitoring in power-constrained environments
  • Deployment on neuromorphic chips (BrainChip Akida, Intel Loihi)

πŸ“Š Training Your Own Model

Basic Training

from src.neuroids_v4 import NeuroIDS, NetworkConfig, create_ids_network
from src.data import DataLoader, normalize_features

# Load data
loader = DataLoader('data/NSL-KDD')
X_train, y_train = loader.load_train()
X_test, y_test = loader.load_test()

# Normalize
X_train, stats = normalize_features(X_train)
X_test, _ = normalize_features(X_test, stats=stats)

# Create model
model = create_ids_network('standard')  # or 'lightweight', 'deep', 'accurate'

# Train
history = model.fit(
    X_train, y_train,
    epochs=20,
    validation_data=(X_test, y_test),
    patience=5,
    verbose=True
)

# Save
model.save('my_model.pkl')

Custom Configuration

from src.neuroids_v4 import NeuroIDS, NetworkConfig

config = NetworkConfig(
    input_size=41,
    hidden_sizes=[256, 128, 64],  # Deeper network
    output_size=5,
    time_steps=150,               # Longer simulation
    v_thresh=0.5,
    tau_m=15.0,
    spike_rate=0.3,
    learning_rate=0.01,
    weight_decay=0.0001
)

model = NeuroIDS(config)

With Data Augmentation

from src.data_augmentation import balance_dataset, AugmentationConfig

# Balance training data
aug_config = AugmentationConfig(
    min_samples_per_class=2000,
    target_ratio=0.6,
    smote_k_neighbors=5
)
X_balanced, y_balanced = balance_dataset(X_train, y_train, aug_config)

# Train on balanced data
model.fit(X_balanced, y_balanced, ...)

πŸ”¬ Reproducing Paper Results

To reproduce the results from the paper:

# Full training with synthetic validation + NSL-KDD
python examples/train_nslkdd.py

Expected output:

Overall Accuracy: 0.7342
  normal: P=0.711 R=0.879 F1=0.786
  dos:    P=0.900 R=0.674 F1=0.771
  probe:  P=0.644 R=0.829 F1=0.725
  r2l:    P=0.645 R=0.337 F1=0.443
  u2r:    P=0.106 R=0.692 F1=0.184

🎯 Use Cases

Tactical/Military Networks

  • Forward operating bases with limited power
  • Unmanned systems (drones, UGVs)
  • Satellite communication endpoints

IoT/Edge Security

  • Smart grid monitoring
  • Industrial control systems
  • Connected vehicle networks

Resource-Constrained Environments

  • Remote sensors
  • Battery-powered devices
  • Embedded security appliances

πŸ“ˆ Future Work

  • Hardware validation on BrainChip Akida
  • Intel Loihi deployment
  • STDP-based unsupervised pre-training
  • Temporal/latency encoding schemes
  • Evaluation on CICIDS2017/2018 datasets
  • Adversarial robustness analysis β†’ NeuroIDS-Adversarial

πŸ“„ Citation

If you use NeuroIDS in your research, please cite:

@article{davis2026neuroids,
  title={NeuroIDS: Energy-Efficient Intrusion Detection Using Spiking Neural
         Networks for Tactical Network Defense},
  author={Davis, Toby R.},
  doi={10.13140/RG.2.2.23827.13604},
  year={2026}
}

πŸ“ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

  • Department of Defense Cyber Service Academy Scholarship Program
  • Mississippi State University Department of Computer Science and Engineering
  • NSL-KDD dataset creators at the University of New Brunswick

πŸ“§ Contact

Toby R. Davis M.S. Candidate, Cybersecurity & Operations Mississippi State University Email: trd183@msstate.edu GitHub: @SephDavis


NeuroIDS β€” Bringing neuromorphic computing to cybersecurity πŸ§ πŸ”’

About

Spiking neural network IDS achieving 73.4% accuracy on NSL-KDD at 1,620 pJ per inference. Novel spike count classification solves SNN class collapse, detecting all five attack categories including U2R (69.2% recall from 52 samples). Targeting neuromorphic hardware deployment in power-constrained tactical environments.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages