synaptic_ml
The TensorFlow for Neuromorphic Computing.
Train spiking neural networks. Deploy to neuromorphic chips. Use 1000x less energy than GPU.
import synaptic_ml as sml
# Build a spiking network
model = sml.SpikingNet([784, 256, 10])
model.summary()
# Train with surrogate gradients
model.train(X_train, y_train, epochs=10)
# See the energy advantage
print(sml.energy_comparison_table(model))
# Deploy to neuromorphic hardware
model.deploy(target='akida') # BrainChip Akida (works today, pip install akida)
model.deploy(target='loihi2') # Intel Loihi 2 (via Lava framework)
model.deploy(target='brainscales') # BrainScaleS-2 (via PyNN)
model.deploy(target='cpu') # CPU simulation (default, always works)
Why neuromorphic?
| GPU (A100) | Intel Loihi 2 | BrainChip Akida | Human Brain | |
|---|---|---|---|---|
| Power | 300W | 30mW | 30mW | 20W |
| Energy/inference | ~1000 nJ | ~0.1 nJ | ~1.4 nJ | ~0.001 nJ |
| Available | Yes | Research only | Yes — buy now | No |
The brain uses 20 watts. GPT-4 uses 50 megawatts. That is a 2.5 million x gap.
Neuromorphic chips close that gap. synaptic_ml makes them programmable.
Installation
pip install synaptic-ml
Optional hardware backends:
pip install akida # BrainChip Akida (recommended — works without hardware)
pip install lava-nc # Intel Loihi 2 via Lava (requires Python 3.10)
pip install pyNN # BrainScaleS-2 / SpiNNaker 2
Hardware Backends
| Backend | Chip | Install | Hardware needed? |
|---|---|---|---|
cpu |
CPU simulation | built-in | No |
akida |
BrainChip AKD1000/AKD1500 | pip install akida |
No (virtual mode) |
loihi2 |
Intel Loihi 2 | pip install lava-nc |
No (CPU sim via Lava) |
brainscales |
BrainScaleS-2 | pip install pyNN |
Apply at ebrains.eu |
BrainChip Akida — works today
# No hardware needed — runs in virtual simulation
backend = model.deploy(target='akida')
# With real AKD1000/AKD1500 hardware connected
backend = model.deploy(target='akida', use_hardware=True)
Buy Akida hardware: brainchipinc.com/products
Intel Loihi 2 — via Lava
# Lava is Intel's official open-source neuromorphic framework
# synaptic_ml sits on top of it as a friendly API layer
backend = model.deploy(target='loihi2')
For real Loihi 2 hardware, join the INRC: neuromorphic.intel.com
Neuron Models
# Leaky Integrate-and-Fire (default, fast)
model = sml.SpikingNet([784, 256, 10], neuron='lif')
# Adaptive LIF (spike-frequency adaptation)
model = sml.SpikingNet([784, 256, 10], neuron='adaptive_lif')
# Izhikevich (biologically rich: bursting, chattering, fast-spiking)
model = sml.SpikingNet([784, 256, 10], neuron='izhikevich')
Spike Encoders
import numpy as np
x = np.random.rand(784) # values in [0, 1]
# Rate coding — spike probability proportional to value (most common)
enc = sml.RateEncoder(time_steps=100, max_rate=100)
spikes = enc.encode(x) # shape: (100, 784)
# Temporal — earlier spike = stronger signal (most energy efficient)
enc = sml.TemporalEncoder(time_steps=100)
spikes = enc.encode(x) # at most 1 spike per neuron
# Population — Gaussian tuning curves (most biologically realistic)
enc = sml.PopulationEncoder(n_neurons=10, sigma=0.5)
spikes = enc.encode(x)
# Delta — spikes only on change (perfect for IoT sensors)
enc = sml.DeltaEncoder(threshold=0.05)
spikes = enc.encode_series(time_series)
Learning Rules
# Surrogate gradients (recommended) — backprop through spike nonlinearity
# Uses voltage-based soft activations + Adam optimizer for stable training.
model.train(X, y, learning_rule='surrogate', learning_rate=0.001, epochs=30)
# STDP — unsupervised, no labels needed, biologically inspired
model.train(X, y, learning_rule='stdp')
# Custom trainer with validation split
trainer = sml.Trainer(model, learning_rule='surrogate', learning_rate=0.001)
trainer.fit(X_train, y_train, epochs=50, validation_split=0.1)
trainer.evaluate(X_test, y_test)
ANN to SNN Conversion
Convert your existing PyTorch or Keras models to SNNs in one line:
import torch.nn as nn
# Your trained ANN
ann = nn.Sequential(nn.Linear(784, 256), nn.ReLU(), nn.Linear(256, 10))
# Convert to SNN (threshold balancing)
snn = sml.convert_from_pytorch(ann, X_calibration, time_steps=100)
# Deploy to neuromorphic hardware
snn.deploy(target='akida')
Energy Analysis
# After running predictions
model.predict(X_test)
# Detailed energy breakdown
energy = model.estimate_energy()
print(f"Ops/inference: {energy['synaptic_ops_per_inference']:,.0f}")
print(f"Energy/inference: {energy['energy_per_inference_nJ']:.4f} nJ")
print(f"vs GPU: {energy['efficiency_gain']:.0f}x more efficient")
# Full comparison table
print(sml.energy_comparison_table(model))
Save / Load
model.save('my_snn.snm')
model = sml.SpikingNet.load('my_snn.snm')
Examples
# MNIST classification with LIF neurons + surrogate gradients
python examples/mnist_lif.py
# Unsupervised pattern learning with STDP
python examples/pattern_recognition.py
# IoT anomaly detection with delta encoding
python examples/edge_sensor.py
# Quick self-test
python -m synaptic_ml
Architecture
synaptic_ml/
├── core/
│ ├── neurons.py # LIF, Adaptive LIF, Izhikevich
│ ├── synapses.py # Dense, Sparse, Delayed
│ ├── layers.py # LIFLayer, OutputLayer, etc.
│ └── network.py # SpikingNet (main model class)
├── encoding/
│ ├── rate.py # Poisson rate coding
│ ├── temporal.py # Time-to-first-spike, phase coding
│ └── population.py # Gaussian tuning, delta/event coding
├── learning/
│ ├── stdp.py # STDP, reward-modulated STDP
│ ├── surrogate.py # Surrogate gradient functions
│ └── conversion.py # ANN->SNN threshold balancing
├── backends/
│ ├── cpu.py # Pure numpy simulation
│ ├── akida.py # BrainChip Akida (pip install akida)
│ ├── loihi2.py # Intel Loihi 2 (via Lava)
│ └── brainscales.py # BrainScaleS-2 (via PyNN)
├── training/
│ └── trainer.py # Training loop, surrogate + STDP
└── utils/
├── metrics.py # Energy, spike metrics, Van Rossum distance
└── visualization.py # Raster plots, membrane traces, energy bars
Roadmap
- LIF, Adaptive LIF, Izhikevich neuron models
- Rate, Temporal, Population, Delta encoders
- LIF, Adaptive LIF, Izhikevich neuron models
- Rate, Temporal, Population, Delta encoders
- Surrogate gradient training (BPTT with momentum, voltage-based soft activations)
- STDP + Reward-modulated STDP
- ANN->SNN conversion (threshold balancing)
- BrainChip Akida backend (CPU virtual mode + hardware mode)
- Intel Loihi 2 backend (via Lava framework)
- BrainScaleS-2 backend (via PyNN)
- 111-test suite (neurons, encoders, layers, network, backends, learning)
- GPU simulation (CuPy backend)
- SpiNNaker 2 backend
- Innatera T1 backend
- IBM NorthPole backend (when SDK releases)
- Quantization-aware training
- Online/streaming inference API
- Pretrained model hub
Contributing
See CONTRIBUTING.md.
Most needed right now:
- Someone with Loihi 2 hardware to test and fix the Loihi 2 backend
- Someone with Akida AKD1000/AKD1500 hardware to test hardware mode
- GPU simulation via CuPy
- MNIST/CIFAR benchmarks — real-world accuracy numbers
License
MIT License — see LICENSE.
Copyright (c) 2026 Hrishikesh Rajulu
The brain uses 20 watts. GPT-4 uses 50 megawatts. synaptic_ml bridges that gap.
Metadata
Release files for synaptic-ml 0.1.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| synaptic_ml-0.1.4.tar.gz | 48.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| synaptic_ml-0.1.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 105.2 kB
Release files / synaptic_ml-0.1.4.tar.gz
| Download URL | synaptic_ml-0.1.4.tar.gz |
|---|---|
| Size | 48.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e0cb558c13e3c9993186d2a7d80291e77e1920bc1073eeab2b565bcf77b02d03
|
|
BLAKE2b-256 checksum How to use checksums |
5a749363839c78964fe45bec1c8c6e3012b419a0aa80be18a35b0d95cc45f1ba
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.5
|
Release files / synaptic_ml-0.1.4-py3-none-any.whl
| Download URL | synaptic_ml-0.1.4-py3-none-any.whl |
|---|---|
| Size | 57.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
50b0ce782f9275379e3340846c6bec4c5308db36b76c409332448506f89706ca
|
|
BLAKE2b-256 checksum How to use checksums |
f759d7e0af14a9ef5f25c9a3d0fa296868c7e30a75a042e135d653dcff32d5a1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.5
|