This repository implements Local Timescale Gates (LT-Gate) for spiking neural networks, along with baseline algorithms HLOP and DSD-SNN. The codebase supports training and evaluation on temporally distinct datasets, with a focus on continual learning scenarios.
lt-gates/
├── configs/ # Configuration files for different algorithms and experiments
│ ├── ltgate.yaml # LT-Gate hyperparameters and training settings
│ ├── hlop.yaml # HLOP baseline configuration
│ └── ablations/ # Ablation study configurations
├── data/ # Dataset storage
│ ├── fast/ # Fast temporal dataset (1kHz)
│ └── slow/ # Slow temporal dataset (50Hz)
├── src/ # Source code
│ ├── algorithms/ # Algorithm implementations
│ │ ├── ltgate.py # LT-Gate implementation
│ │ └── hlop.py # HLOP baseline implementation
│ ├── layers/ # Neural network layers
│ │ ├── dual_lif_neuron.py # Dual-pathway LIF neuron
│ │ ├── dual_conv_lif.py # Dual convolutional LIF layer
│ │ ├── lt_conv.py # LT-Gate convolutional layer
│ │ └── hlop_subspace.py # HLOP subspace projection layer
│ ├── data_loader.py # Dataset loading utilities
│ ├── model.py # SNN backbone architecture
│ └── train.py # Training pipeline entry point
└── tests/ # Unit and integration tests
├── test_ltgate.py # LT-Gate unit tests
├── test_hlop.py # HLOP unit tests
└── test_backbone.py # Backbone integration tests
- LT-Gate Algorithm: Implementation of Local Timescale Gates for adaptive temporal processing
- Baseline Algorithms: HLOP and DSD-SNN implementations for comparison
- Flexible SNN Backbone: Configurable backbone supporting all algorithms
- Multi-Platform Support:
- CPU/GPU training via PyTorch
- Loihi 2 neuromorphic deployment
- Akida runtime/energy measurements
- Comprehensive Testing: Unit tests and integration tests for all components
- Experiment Tools:
- Dataset generation and validation
- Training pipeline with checkpointing
- Evaluation metrics and logging
- Statistical analysis and plotting
- Python 3.8+
- PyTorch 2.0+
- CUDA 11.8+ (for GPU support)
- h5py
- numpy
- tqdm
- pyyaml
- matplotlib
- seaborn
- pandas
- pingouin (for statistical analysis)
Optional dependencies:
- lava-dl (for Loihi 2 deployment)
- akida (for Akida runtime measurements)
- Clone the repository:
git clone https://github.com/ansschh/lt-gate.git
cd lt-gate- Create a virtual environment:
python -m venv venv
source venv/bin/activate # Linux/Mac
# OR
.\venv\Scripts\activate # Windows- Install dependencies:
pip install -r requirements.txtGenerate and validate dataset splits:
python src/generate_splits.py --fast-rate 1000 --slow-rate 50Train LT-Gate model:
python src/train.py --config configs/ltgate.yaml --gpuTrain HLOP baseline:
python src/train.py --config configs/hlop.yaml --alg hlop --gpuRun evaluation metrics:
python src/evaluate.py --model-path ckpts/ltgate_best.ptRun ablation experiments:
python analysis/ablation_runner.py --config configs/ablations/Generate ablation plots:
python analysis/plot_ablation.py --results-dir results/ablation/Example LT-Gate configuration (configs/ltgate.yaml):
model:
backbone: "dual_conv"
input_size: [1, 28, 28]
hidden_size: 256
num_classes: 10
training:
batch_size: 32
epochs: 100
lr: 0.001
optimizer: "adam"
scheduler: "cosine"
ltgate:
tau_fast: 1.0
tau_slow: 20.0
gamma_init: 0.5
eta_gamma: 0.01- Fork the repository
- Create a feature branch
- Make your changes
- Run tests:
python -m pytest tests/ - Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
If you use this code in your research, please cite:
[Citation details will be added upon publication]