Skip to main content

Import

snn.Sequential

A temporally-unrolled SNN container. Applies layers in order across all T timesteps. Owns and threads LIF state across timesteps — callers do not manage membrane tensors directly.
Parameters Input / Output shape
  • Input: [T, batch, in_features] — time-first
  • Output: [T, batch, out_features] — time-first, spike raster of the last layer
Notes
  • Sequential is a torch.nn.Module. .parameters(), .state_dict(), .to(device), and all standard PyTorch optimizer integrations work as expected.
  • LIF state is reset to zero at the start of every forward call. It is not persistent across batches.
  • Non-LIF layers (Dense, Conv2d, standard torch.nn modules) are called without state at each timestep.
Example

snn.Dense

A linear (fully-connected) layer.
Parameters Weight initialization Kaiming uniform (fan-in mode), matching torch.nn.Linear. Notes
  • Equivalent to torch.nn.Linear. No temporal state.
  • Applied at every timestep independently.

snn.LIF

A layer of leaky integrate-and-fire neurons.
Parameters Computed constants The simulation timestep is fixed at dt = 1.0 ms. It is a class constant (LIF.DT), not a constructor parameter. Per-timestep update
Reset modes
  • "subtract" — membrane potential is reduced by threshold on each spike. Gradients flow through the subtraction path.
  • "zero" — membrane potential is reset to zero on each spike. The reset mask is detached from the gradient graph.
Notes
  • LIF has no weight parameters. Its size is inferred from the output of the preceding layer.
  • tau_mem must be strictly greater than 1.0 ms. A time constant at or below the timestep loses all membrane history within a single step.
  • Surrogate gradient: fast-sigmoid. See Surrogate Gradients and E0101.

snn.Conv2d

A 2D convolutional layer for spatial spike inputs (event-camera data, 2D feature maps).
Parameters Input / Output shapes
  • Input per timestep: [batch, C_in, H, W]
  • Output per timestep: [batch, C_out, H_out, W_out]
When used inside Sequential, the container calls it at each of the T timesteps.

Training

All THRINDEX layers are torch.nn.Module subclasses. A standard PyTorch training loop works without modification:
The surrogate gradient (FastSigmoid) handles the non-differentiable spike function during loss.backward(). BPTT gradients flow through all T timesteps automatically via PyTorch autograd.

Compiling a trained model

See Hardware Targets for the AKD1500 deployment guide.