File size: 4,654 Bytes
d043647 6bbdc56 d043647 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 | ---
license: mit
library_name: pytorch
tags:
- spiking-neural-network
- neuroscience
- connectome
- drosophila
- olfaction
- norse
- biology
datasets:
- MIRE-org/door-olfactory-responses
pipeline_tag: tabular-classification
---
# FlyWire Olfactory SNN (MaskedRecurrentLIFSNN)
A **connectome-constrained recurrent spiking neural network** for odor identity
classification in *Drosophila melanogaster*, trained on the
[DoOR](https://github.com/ropensci/DoOR.data) olfactory receptor response dataset.
## Model description
The recurrent connectivity of this SNN is fixed to the **FlyWire** connectome
subgraph (antennal lobe projection neurons + mushroom body Kenyon cells). Synaptic
signs (excitatory/inhibitory) come from predicted neurotransmitter types in FlyWire.
Only the **weight magnitudes** are learned; the topology is biological.
### Architecture
```
Input: odor receptor vector (DoOR: ~52 receptors)
β Linear(input_dim β hidden_dim, no bias)
β 20 LIF timesteps with:
β’ Poisson spike encoding from rate-coded input
β’ Recurrent current: spk Γ (W_rec β mask β sign)α΅
β’ Norse LIFCell (surrogate gradient, Ξ±=100)
β time-averaged spike rates
β Linear(hidden_dim β num_classes)
```
- **Neuron model:** Leaky Integrate-and-Fire (Norse `LIFCell`, `method="super"`)
- **Recurrent mask:** Binary from FlyWire adjacency (fixed, not learned)
- **Synaptic signs:** ACh/DA/5-HT/OA β +1 (excitatory); GABA/Glu β β1 (inhibitory)
- **Training:** Adam optimizer, CrossEntropyLoss, surrogate gradients through LIF
## Files
| File | Description |
|------|-------------|
| `model.safetensors` | Trained weights (best validation checkpoint) |
| `config.json` | Architecture hyperparameters |
| `connectome_mask.npz` | FlyWire olfactory subgraph (binary adjacency + signs) |
| `connectome_meta.json` | Connectome metadata (neuron count, edge count, source) |
| `modeling_snn.py` | Standalone `MaskedRecurrentLIFSNN` class |
## Usage
```python
import scipy.sparse as sp
import torch
from safetensors.torch import load_file
# Load the model
from modeling_snn import MaskedRecurrentLIFSNN
adjacency = sp.load_npz("connectome_mask.npz")
model = MaskedRecurrentLIFSNN(
input_dim=52, # from config.json
hidden_dim=800, # from config.json
num_classes=500, # from config.json
adjacency=adjacency,
steps=20,
alpha=100.0,
)
state_dict = load_file("model.safetensors")
model.load_state_dict(state_dict)
model.eval()
# Inference
x = torch.randn(1, 52) # receptor activation vector
logits, spike_sparsity = model(x)
predicted_odor = logits.argmax(dim=1).item()
```
## Training details
- **Dataset:** DoOR (Database of Odorant Responses) β CC BY-SA 4.0
- **Cross-validation:** 5-fold over odor identities Γ 5 seeds = 25 runs
- **Early stopping:** patience 5 on validation accuracy
- **Optimizer:** Adam (lr=1e-3, weight_decay=1e-5)
- **Batch size:** 32
- **Max epochs:** 80
- **SNN timesteps:** 20
- **Evaluation:** 5Γ Monte Carlo averaging over stochastic Poisson encoding
## Connectome-Constrained Spiking Neural Networks Olfactory Classification Study
This model was used in a classification study and ran against a comparable but shuffled spiking neural network Sparse MLP, and Dense MLP models.
Summary Results may be found here: https://mire-institute.org/research-papers/connectomeconstrained-spiking-neural-networks-olfactory-classification-study
And the full research paper may be found here: https://mire-institute.org/research-papers/connectomeconstrained-spiking-neural-networks-olfactory-classification-study-preprint
## Biological basis
The model's recurrent topology is extracted from the [FlyWire](https://flywire.ai/)
whole-brain connectome of *Drosophila melanogaster* (FAFB dataset). The olfactory
subgraph includes:
- **Antennal Lobe Projection Neurons (ALPN):** relay processed odor information
- **Kenyon Cells (KC):** mushroom body neurons for associative olfactory memory
This captures the AL β PN β KC pathway that the fly uses for odor discrimination
and learning.
## Citation
If you use this model, please cite:
- The **DoOR** database: MΓΌnch & Galizia (2016). DoOR 2.0 β Comprehensive mapping
of *Drosophila melanogaster* odorant responses. *Scientific Reports*, 6, 21841.
https://doi.org/10.1038/srep21841
- The **FlyWire** connectome: Dorkenwald et al. (2024). Neuronal wiring diagram of
an adult brain. *Nature*, 634, 124β138. https://doi.org/10.1038/s41586-024-07558-y
|