OpenViSTAI · Agents · Blockchain · Crypto
Menu
AI Developer Tools & SDKs

Snntorch

Snntorch is a Python library for developing and training spiking neural networks, including deep and online learning, in a PyTorch-oriented ecosystem.

Independent OpenViST project profile, based on linked sources.

Snntorch — OpenViST project profile in AI Developer Tools & SDKs.
OpenViST project illustration. See the linked sources for product details.
Understand the project

Practical overview

When it fits

Use Snntorch when your development work specifically involves spiking neural networks, neuron models, or deep and online learning with spiking neural networks.

Who it is for

  • Python developers exploring spiking neural networks and neuron models.
  • Machine-learning practitioners prototyping deep or online learning with spiking neural networks.

Documented uses

  • Develop spiking-neural-network learning experiments in Python.
  • Prototype online learning with spiking neural networks.
  • Explore neuron-model implementations in a PyTorch-oriented project.
Before you choose

Requirements & limits

  • The library is Python-based and its repository identifies PyTorch in its ecosystem.
  • The project describes its scope as deep and online learning with spiking neural networks.
  • The public repository lists an MIT license.

Check current requirements in the official documentation. Source-based guidance does not mean OpenViST has run or independently tested this project.

Source-based practical guide

Build and evaluate a simple spiking neural network

Define a PyTorch network with snntorch Leaky neurons and process input over multiple time steps to record spike and membrane-potential outputs.

Before you start

  • Python with PyTorch and snntorch available.
  • Input data and defined values for input, hidden, and output layer sizes.
  • A device value for the network, as used in the example.

Steps

  1. Import torch, torch.nn, and snntorch; set the neuron decay parameter and number of time steps.

  2. Define a torch.nn.Module with linear layers and snntorch.Leaky neurons; initialize each neuron's membrane state with init_leaky().

  3. In forward(), iterate for the configured number of steps, pass each layer's current or spikes through the next layer, and record output spikes and membrane potentials.

  4. Stack the recorded outputs, move the network to the chosen device, and call it with data to obtain spike and membrane-potential traces.

Expected outcome

A PyTorch network processes input over the configured time steps and returns recorded output spikes and membrane potentials.

Guide limitations

  • The example assumes suitable input data, layer dimensions, and a defined device; it does not document data preparation or training.
  • The example initializes hidden state manually. The documentation notes init_hidden=True as an alternative, and describes moving the time-step loop into the training loop when backward passes are needed before all time steps finish.
Source-based practical guide

Export a snntorch model to NIR

Convert a defined snntorch PyTorch model to a Neuromorphic Intermediate Representation graph using sample input.

Before you start

  • A snntorch model represented as a PyTorch module, such as a Sequential model.
  • A torch.Tensor of sample input compatible with the model.
  • The nirtorch dependency used by the export function.

Steps

  1. Import torch, snntorch, and export_to_nir from snntorch.export_nir.

  2. Define a model, for example a Sequential network containing Flatten, Linear layers, and Leaky neurons.

  3. Create sample_data with a shape compatible with the model.

  4. Call export_to_nir(net, sample_data) and retain the returned NIR graph.

Expected outcome

The export function returns a graph-based NIR representation of the model.

Guide limitations

  • The model must be extractable as a PyTorch computational graph; sample_data must be compatible with its input.
  • The documentation identifies conversion support for recurrent RLeaky and RSynaptic layers, but does not describe deployment or execution on a particular target platform.
Evidence and transparency

Sources & review

Source record details
Source availability
Active
Sources checked
11 October 2026
Original website title
jeshraghian/snntorch · Official homepage title · retained in its source language