The membrane equation
The leaky integrate-and-fire (LIF) neuron is the workhorse of computational neuroscience and the primary building block of THRINDEX models. Its dynamics are described by a first-order linear differential equation: Where:V(t)is the membrane potential at timetτ_mem(tau_mem) is the membrane time constant — how quickly the potential decays without inputI(t)is the input current (the weighted sum of incoming spikes)
V(t) reaches the threshold θ, the neuron emits a spike and resets.
Discrete-time form
In simulation and on digital hardware, time is discretized into steps of sizeΔt (dt). The continuous equation becomes a recurrence:
The factor α (alpha) is the leak factor: how much of the current potential survives to the next timestep. For τ_mem = 20ms and dt = 1ms, α ≈ 0.951. For smaller τ_mem, the neuron forgets faster.
THRINDEX computes
α exactly as exp(-dt / tau_mem) at compile time and stores the resolved constant in the .thx artifact. The Python model stores tau_mem and dt; the artifact stores alpha. You never set alpha directly.Parameters
Reset modes
After a spike, the membrane potential is reset. THRINDEX supports two modes: Subtract (reset="subtract", default): the threshold is subtracted from the current potential.
If the potential exceeded the threshold by 0.3, the post-spike potential is 0.3, not zero. This preserves information about the excess charge.
Zero (reset="zero"): the potential is set to zero unconditionally after a spike.
Simpler, but discards the overshoot. Use subtract mode unless you have a specific reason to zero the potential.
Synaptic dynamics
A singlesnn.LIF layer in THRINDEX couples a dense layer (the synapse) with the LIF integrator. The input current is the output of the preceding linear transformation:
tau_syn is specified, THRINDEX adds a first-order synaptic filter before the membrane integrator — the input current itself decays with time constant tau_syn:
Most practical models use the default (tau_syn not set), which means input is injected directly into the membrane. Add tau_syn when the application requires temporal smoothing of the input current.
What a LIF layer computes, step by step
For each timestept = 0, 1, ..., T-1:
- Compute input current:
I[t] = W · x[t] + b(the preceding Dense layer) - Update membrane:
V[t] = α · V[t-1] + I[t] - Check threshold:
spike[t] = 1 if V[t] ≥ threshold else 0 - Apply reset:
V[t] = V[t] - threshold · spike[t](subtract mode)
spike[0..T-1] — a binary matrix of shape [T, n_neurons].
In code
T dimension automatically. It resets to zero at the start of each new sample in the batch.