ignore_and_fire#
- class brainpy.state.ignore_and_fire(in_size, phase=1.0, rate=Quantity(10., 'Hz'), name=None)#
Ignore-and-fire neuron model for generating spikes at fixed intervals.
Description
The
ignore_and_fireneuron is a neuron model that generates spikes at a predefinedratewith a constant inter-spike interval (“fire”), irrespective of its inputs (“ignore”). In this simplest version of theignore_and_fireneuron, the inputs from other neurons or devices are not processed at all.This is a brainpy.state re-implementation of the NEST simulator model of the same name, using NEST-standard parameterization.
1. Model equations and dynamics
The model’s internal state variable, the
phase, describes the time to the next spike relative to the firing period (the inverse of therate).The firing period (in simulation time steps) is computed as:
\[T_{\text{fire}} = \text{round}\!\left(\frac{1}{\text{rate}} \times 1000\right) / dt\]where rate is in spikes/s and the result is expressed in simulation time steps (NEST rounds this to the simulation grid via
Time::get_steps()).The initial phase countdown (in simulation time steps) is computed as:
\[N_{\text{phase}} = \text{round}\!\left(\frac{\text{phase}}{\text{rate}} \times 1000\right) / dt\]In each update step, the model checks whether the countdown has reached zero:
If
phase_steps == 0: a spike is emitted and the countdown is reset tofiring_period_steps - 1.Otherwise: the countdown is decremented by 1.
To create asynchronous activity for a population of
ignore_and_fireneurons, the firing phases can be randomly initialized.2. Assumptions, constraints, and computational implications
The model assumes unit-compatible parameters and broadcast-compatible shapes against
self.varshape.The
phaseparameter must satisfy \(0 < \text{phase} \le 1\), representing fractional position within the firing period.The
rateparameter must be positive. Extremely low rates (< 1/1000 Hz) may cause integer overflow when converting to time steps.Per-step compute is \(O(\prod \mathrm{varshape})\) with vectorized elementwise operations (phase countdown and spike emission).
All inputs to
update()are completely ignored; the model fires deterministically based solely on its internal clock.
Note
The
ignore_and_fireneuron is primarily used for neuronal-network model verification and validation purposes (“benchmarking”), in particular, to evaluate the correctness and performance of connectivity generation and inter-neuron communication. It permits an easy scaling of the network size and/or connectivity without affecting the output spike statistics. The amount of network traffic is predefined by the user, and therefore fully controllable and predictable, irrespective of the network size and structure.Note
This model inherits from
Dynamicsrather thanNeuronbecause it has no membrane potential, no threshold-based spike generation, and no subthreshold dynamics. Surrogate gradients and spike reset mechanisms are therefore not applicable.- Parameters:
in_size (
Size) – Population shape specification. All neuron parameters are broadcast toself.varshapederived fromin_size.phase (
ArrayLike, optional) – Initial fractional position within the firing period, where 0 means immediate firing and 1 means firing after a full period. Must satisfy \(0 < \text{phase} \le 1\). Scalar or array broadcast-compatible withvarshape. Unitless. Default is1.0.rate (
ArrayLike, optional) – Firing rate in spikes per second. Must be positive. Scalar or array broadcast-compatible withvarshape. Default is10. * u.Hz.name (
strorNone, optional) – Optional node name passed tobrainstate.nn.Dynamics.
Parameter Mapping
Table 22 Parameter mapping to NEST ignore_and_fire#Parameter
Default
Math symbol
Semantics
phase1.0\(\phi \in (0, 1]\)
Fractional position in firing period; 1.0 = full period delay.
rate10.0Hz\(f\) (Hz)
Spike rate; firing period \(T = 1/f\).
- phase_steps#
Integer countdown to next spike (in simulation time steps). Decrements each step; fires when reaching zero.
- Type:
ShortTermState
- firing_period_steps#
Integer duration of firing period (in simulation time steps). Constant after initialization.
- Type:
ShortTermState
Examples
Create an
ignore_and_fireneuron with 10 Hz firing rate:>>> import brainpy >>> import brainstate >>> import saiunit as u >>> >>> # Create an ignore_and_fire neuron with 10 Hz firing rate >>> neuron = brainpy.state.ignore_and_fire(1, rate=10.0 * u.Hz) >>> >>> # Initialize the state >>> neuron.init_state() >>> >>> # Step the neuron and check for spikes >>> with brainstate.environ.context(dt=0.1 * u.ms, t=0.0 * u.ms): ... spike = neuron.update() ... print(f"Spike: {spike}")
Create a population with random phases for asynchronous activity:
>>> import numpy as np >>> # Create 100 neurons with random initial phases >>> phases = np.random.uniform(0.01, 1.0, size=100) >>> neurons = brainpy.state.ignore_and_fire(100, phase=phases, rate=20.0 * u.Hz)
References
- __init__(in_size, phase=1.0, rate=Quantity(10., 'Hz'), name=None)[source]#
Initialize the ignore_and_fire neuron model.
Stores parameters, initializes base
Dynamicsstate, and validates parameter constraints. Does not initialize internal state variables (phase_steps,firing_period_steps); callinit_state()before simulation.- Parameters:
in_size (
Size) – Population shape specification passed tobrainstate.nn.Dynamics. Determinesself.varshape.phase (
ArrayLike, optional) – Initial fractional position within the firing period. Must satisfy \(0 < \text{phase} \le 1\). Broadcast tovarshapeviabraintools.init.param(). Default is1.0.rate (
ArrayLike, optional) – Firing rate in spikes per second. Must be positive. Broadcast tovarshapeviabraintools.init.param(). Default is10. * u.Hz.name (
strorNone, optional) – Optional node name passed tobrainstate.nn.Dynamics.
- Raises:
ValueError – If
phaseviolates \(0 < \text{phase} \le 1\) orrateis not strictly positive, raised by_validate_parameters().
See also
init_stateInitialize state variables before simulation.
updatePerform one simulation time step.
- init_state(batch_size=None, **kwargs)[source]#
Initialize internal state variables for simulation.
Computes and stores
firing_period_stepsandphase_stepsasbrainstate.ShortTermStatearrays. Both are derived from therateandphaseparameters via_calc_initial_variables().- Parameters:
- Raises:
ValueError – If
phaseis not in \((0, 1]\) orrateis not positive, raised during_validate_parameters()called in__init__().
Side Effects
Creates or overwrites the following instance attributes:
self.firing_period_steps:brainstate.ShortTermStateself.phase_steps:brainstate.ShortTermState
Notes
This method must be called before the first
update()call, typically vianeuron.init_state()or automatically through higher-level APIs likebrainstate.nn.Module.init_all_states().
- update(x=None)[source]#
Update the ignore_and_fire neuron for one simulation time step.
Decrements the internal phase countdown and emits spikes when the countdown reaches zero. All external inputs are completely ignored.
The update logic follows NEST’s deterministic firing schedule:
Check if
phase_steps == 0:If yes: emit spike (output 1.0), reset countdown to
firing_period_steps - 1.If no: emit no spike (output 0.0), decrement countdown by 1.
Update
self.phase_stepswith the new countdown value.
- Parameters:
x (
ArrayLikeorNone, optional) – Input signal (ignored). Accepted for API compatibility with other neuron models but has no effect on the dynamics. Any value or shape is permitted; the parameter is never accessed.- Returns:
spike – Float array with shape
varshape(or(batch_size, *varshape)if initialized with batching). Contains1.0at positions where a spike is emitted this step and0.0elsewhere. Dtype isfloat32or the default JAX float dtype.- Return type:
jnp.ndarray
Notes
This method must be called after
init_state(). Callingupdate()before initialization will raise anAttributeErrordue to missingphase_stepsstate.The spike output is suitable for direct use as delta-synapse input (units of spikes/step) or as a binary event indicator for recording.