A Neuromorphic AI application that recognizes handwritten digits using biologically inspired Leaky Integrate-and-Fire (LIF) neurons, temporal spike processing, and interactive visualization.
Neuromorphic Spiking Neural Network (SNN) Digit Classifier is an end-to-end Deep Learning application that classifies handwritten digits (0β9) using Spiking Neural Networks (SNNs) instead of conventional Artificial Neural Networks (ANNs).
Unlike traditional neural networks that process continuous activation values, SNNs communicate using discrete spikes over time, closely resembling how neurons communicate inside the human brain.
The project is built using PyTorch, snnTorch, and Torchvision, and deployed through an interactive Streamlit dashboard where users can draw digits, visualize spike activity, inspect output neuron firing, and observe the decision-making process of a neuromorphic neural network.
This project aims to:
- Learn Neuromorphic AI fundamentals
- Understand Spiking Neural Networks
- Simulate biological neuron behavior
- Train an SNN on the MNIST dataset
- Visualize temporal spike activity
- Build an interactive AI dashboard
- Demonstrate energy-efficient AI concepts
Implements a biologically inspired neural architecture using:
- Leaky Integrate-and-Fire (LIF) neurons
- Temporal spike propagation
- Membrane potential dynamics
- Spike accumulation
- Surrogate gradient learning
Users can:
- Draw handwritten digits
- Clear the canvas
- Predict instantly
- Observe live inference
The dashboard displays:
- Output neuron spikes
- Spike counts
- Raster plots
- Temporal firing activity
- Prediction confidence
Visualize:
- Softmax probabilities
- Spike accumulation
- Winning neuron
- Confidence score
Built with:
- Streamlit
- Plotly
- Dark Theme UI
- Interactive Components
Traditional neural networks communicate using continuous numbers.
Neuron A
β
βΌ
Activation = 0.82
Spiking Neural Networks communicate using discrete spikes over time.
Time β
Neuron A
0 0 1 0 0 1 1 0 0 1
This temporal behavior closely resembles biological neurons and enables energy-efficient computation suitable for neuromorphic hardware.
The project uses Leaky Integrate-and-Fire (LIF) neurons.
Each neuron:
- Integrates incoming current
- Stores membrane potential
- Leaks over time
- Fires when threshold is crossed
- Resets after firing
[ U_t = \beta U_{t-1} + I_t ]
Where
- (U_t) = Membrane Potential
- (I_t) = Input Current
- (\beta) = Leakage Constant
If
[ U_t \ge U_{threshold} ]
Neuron emits
[ S_t = 1 ]
Otherwise
[ S_t = 0 ]
MNIST Image
(28 Γ 28)
β
βΌ
Flatten (784)
β
βΌ
Fully Connected Layer
(784 β 128)
β
βΌ
Leaky Integrate-and-Fire
Hidden Layer
β
βΌ
Fully Connected Layer
(128 β 10)
β
βΌ
Leaky Integrate-and-Fire
Output Neurons
β
βΌ
Spike Accumulation
β
βΌ
Digit Prediction
Unlike ANNs, inference occurs across 25 simulation time steps.
T = 25
Time β
t0
t1
t2
t3
...
t24
Each neuron may fire multiple spikes.
The digit with the highest accumulated spike count is selected.
MNIST Dataset
β
βΌ
Image Preprocessing
β
βΌ
Flatten Input
β
βΌ
LIF Hidden Layer
β
βΌ
Output LIF Layer
β
βΌ
Spike Accumulation
β
βΌ
Predicted Digit
β
βΌ
Interactive Streamlit Dashboard
snn-digit-classifier/
β
βββ app.py
βββ model.py
βββ train.py
β
βββ models/
β βββ snn_mnist.pth
β
βββ screenshots/
β
βββ requirements.txt
βββ .gitignore
βββ LICENSE
βββ README.md
- Python 3.10+
- PyTorch
- snnTorch
- Torchvision
- Leaky Integrate-and-Fire Neurons
- Surrogate Gradient Learning
- Spike Encoding
- Temporal Learning
- Plotly
- Streamlit
- NumPy
- Pillow
git clone https://github.com/SHALINISAURAV/snn-digit-classifier.git
cd snn-digit-classifierpython -m venv venv
venv\Scripts\activatepython3 -m venv venv
source venv/bin/activatepip install --upgrade pip
pip install -r requirements.txtpython train.pyTraining includes:
- Downloading MNIST
- Building SNN
- Forward propagation
- Spike simulation
- Surrogate backpropagation
- Saving trained weights
streamlit run app.pyOpen
http://localhost:8501
https://snn-digit-classifier-mexwdjvrvwct7yefeqf57f.streamlit.app/
(Add Screenshot)
(Add Screenshot)
(Add Screenshot)
(Add Screenshot)
| Property | Value |
|---|---|
| Dataset | MNIST |
| Model | Spiking Neural Network |
| Hidden Layer | 128 Neurons |
| Output Layer | 10 Neurons |
| Simulation Time | 25 Steps |
| Neuron Model | LIF |
| Learning | Surrogate Gradient |
| Framework | PyTorch + snnTorch |
β Python
β PyTorch
β snnTorch
β Neuromorphic Computing
β Deep Learning
β Artificial Intelligence
β Biological Neural Networks
β Surrogate Gradient Learning
β Streamlit
β Plotly
β Data Visualization
β Interactive Dashboards
β Scientific Computing
β Software Architecture
This project demonstrates:
- Neuromorphic AI
- Spiking Neural Networks
- Temporal Neural Processing
- Biological Learning
- Deep Learning
- Computer Vision
- MNIST Classification
- Interactive AI Applications
- Brain-Inspired Computing
- Human-Computer Interaction
- Convolutional Spiking Neural Networks
- Recurrent SNNs
- Adaptive LIF Neurons
- STDP Learning Rule
- Reward-Based Learning
- Fashion-MNIST Support
- EMNIST Support
- CIFAR10 SNN
- Real Image Recognition
- Webcam Digit Detection
- Live Membrane Potential Visualization
- Hidden Layer Spike Raster
- Layer-wise Activation Viewer
- Confusion Matrix
- Training Dashboard
- TensorBoard Integration
- Docker Deployment
- Cloud Deployment
Contributions are welcome!
-
Fork the repository
-
Create a feature branch
git checkout -b feature-name- Commit your changes
git commit -m "Added new feature"- Push your branch
git push origin feature-name- Open a Pull Request
This project is licensed under the MIT License.
AI Engineer | Deep Learning Engineer | Neuromorphic AI Enthusiast | Machine Learning Developer
- π GitHub: https://github.com/SHALINISAURAV
- πΌ LinkedIn: (Add Your LinkedIn)
- π Portfolio: (Add Your Portfolio)
If you found this project helpful,
β Star this repository
π΄ Fork it
π’ Share it
π Contribute
Built with β€οΈ using PyTorch, snnTorch, Streamlit, Plotly, and Python