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.
Notes
Sequentialis compatible withtorch.nn.Sequentialfor all standard PyTorch operations:.parameters(),.state_dict(),.to(device).- The first layer in a
Sequentialdetermines the model’s input dimension, which is stored in the.thxartifact.
snn.Dense
A linear (fully-connected) layer. Equivalent totorch.nn.Linear but with optional per-connection integer delay support.
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.
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)
n_neuronsis determined by theout_featuresof the precedingDenselayer. There is non_neuronsargument — 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).
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 overT 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:
t and passes the result to the next.