All models

snntorch_leaky_csnn

The snnTorch tutorial 6 convolutional spiking network: LIF neurons on MNIST, trained with surrogate gradients.

Spiking networks · 2,405 operations Checked

100%

Showing the top corner; full diagram not loaded yetShowing a small copy; full diagram not loaded yetLarge diagram, not loaded yet

Open SVG

This diagram has 2,405 operations (71 KB) and is drawn when you ask.

Open in a new tab

Click or tap a spot to read it up close. Scroll or drag inside the diagram to move through it. Zoom with + and − or Ctrl and scroll. Press 0 for the whole graph. Swipe inside the diagram to move through it. Use + and − to zoom.

At a glance

Parameters
29.8K
Operations
2,405
Framework
PyTorch
Recurrent
Yes
Published
Proceedings of the IEEE 2023
Cited by
72 (as of 17 October 2026)
Authors
Jason K. Eshraghian, Max Ward, Emre Neftci and others
License
MIT
Checked
Passed: the trace was replayed operation by operation and matched the model's own output for this input.

Files

The diagram is a drawing of a TorchLens trace of the source code. It contains no code or weights.

Details
Stable ID
m10089
Graph hash
fe9589cf09417cc2bbfb9baddb9ee755ac5900d372942e8c55e74eb3960f87b1
Skeleton hash
756bdc8c092757bb3dff8ae7a88dc22ab1b307864919c4559c9ec4c190b4772f
Architecture hash
cceb058d2509e642aa27d147a9dbf86b43476dc7671f1905cf7718d2ac485991
Diagram SHA-256
ab73746ac706fdbf4e570cb65c7846ddf7e1682e3707537ba536def89418004d
TorchLens version
2.36.0
Renderer
graphviz 2.43.0+pyvips 3.2.0+libvips 8.18.7+render-opts@06c1f0d3
Check
Forward pass replayed in PyTorch

What it is

This is the small convolutional spiking neural network from snnTorch's tutorial 6, trained on MNIST to classify handwritten digits with spikes rather than continuous activations. The snnTorch library is a Python package for gradient-based learning with spiking neural networks that extends PyTorch. The catch with spiking neurons is that spikes are non-differentiable, so ordinary backpropagation needs a workaround.

The architecture is written as 12C5-MP2-64C5-MP2-1024FC10. That reads as a 5 by 5 convolution with 12 filters, 2 by 2 max-pooling, a 5 by 5 convolution with 64 filters, another max-pool, and a fully connected layer mapping 1,024 neurons to 10 outputs. In the network each max-pooled convolution and the final linear layer feed into a Leaky neuron. A Leaky neuron is a leaky integrate-and-fire unit whose membrane potential decays at a rate beta between time steps. A spike is generated when the membrane potential exceeds the threshold. On firing, the reset term subtracts the threshold from the membrane potential. The tutorial simulates the network for num_steps = 50 time steps per batch of inputs. Hidden states of every LIF neuron are reset before each forward pass.

Training uses surrogate gradient descent: on the forward pass the Heaviside step decides whether a neuron spikes, while on the backward pass the gradient of a fast sigmoid stands in for the Dirac delta. The tutorial sets the slope of that fast sigmoid to 25. The slope controls how smooth the surrogate function is and is treated as a hyperparameter. The loss is cross entropy applied to the output spike count, which trains a rate-coded network. After 150 iterations the tutorial reports a test accuracy of 95.70%. The paper adds that snnTorch's default surrogate gradient as of 2023 is a different one, and that the authors have no idea why it works so well.

Key idea. Showing how to modify surrogate gradient descent to overcome the dead neuron problem and use it to construct and train a convolutional spiking neural network.

  • snnTorch
  • CSNN
  • convolutional spiking neural network
  • LIF CSNN
  • snntorch_leaky_csnn
  • leaky integrate-and-fire
  • LIF neuron
  • spiking neural network
  • SNN
  • MNIST
  • surrogate gradient
  • tutorial 6

AI-written summary, based on the paper and checked automatically against it; not reviewed by a person. Corrections welcome.

Cite the paper

@misc{eshraghian2023trainingspikingneuralnetworks,
      title={Training Spiking Neural Networks Using Lessons From Deep Learning}, 
      author={Jason K. Eshraghian and Max Ward and Emre Neftci and Xinxin Wang and Gregor Lenz and Girish Dwivedi and Mohammed Bennamoun and Doo Seok Jeong and Wei D. Lu},
      year={2023},
      eprint={2109.12894},
      archivePrefix={arXiv},
      primaryClass={cs.NE},
      url={https://arxiv.org/abs/2109.12894}, 
}