Skip to main content

Import

snn.Sequential

A sequential container. Layers are applied in the order they are defined. The input propagates through each layer across all T timesteps.
Parameters Notes
  • Sequential is compatible with torch.nn.Sequential for all standard PyTorch operations: .parameters(), .state_dict(), .to(device).
  • The first layer in a Sequential determines the model’s input dimension, which is stored in the .thx artifact.

snn.Dense

A linear (fully-connected) layer. Equivalent to torch.nn.Linear but with optional per-connection integer delay support.
Parameters Weight initialization Weights are initialized with Kaiming uniform initialization (fan-in mode), matching torch.nn.Linear. Delays, if enabled, are initialized to 1 (one-step propagation, the default).

snn.LIF

A layer of leaky integrate-and-fire neurons.
Parameters Computed constants (stored in artifact) Input / Output shapes
  • Input: [batch, T, in_features]
  • Output: [batch, T, n_neurons] — binary spike raster (values are exactly 0.0 or 1.0 in the forward pass; gradients are surrogate-smoothed in the backward pass)
Notes
  • n_neurons is determined by the out_features of the preceding Dense layer. There is no n_neurons argument — the LIF layer infers its size from the input shape on the first forward call.
  • The membrane state is initialized to zero at the start of each sample. It is not persistent across samples in a batch.

snn.Conv2d

A 2D convolutional layer for spatial spike inputs (event-camera data, 2D feature maps).
Parameters Input / Output shapes
  • Input: [batch, T, C_in, H, W]
  • Output: [batch, T, C_out, H_out, W_out]

snn.Flatten

Flattens spatial dimensions. Used between convolutional and dense layers.
  • Input: [batch, T, C, H, W]
  • Output: [batch, T, C × H × W]

Forward pass

All THRINDEX layers process the time dimension in the same way: they iterate over T timesteps and apply the layer computation at each step, maintaining any stateful quantities (membrane potential, synaptic current) across timesteps. The forward pass of a Sequential is equivalent to:
Each layer applies its operation at each t and passes the result to the next.