ml_genn.neurons package
Neuron models describe the dynamics and spiking behaviour of a Population
.
- class ml_genn.neurons.AdaptiveLeakyIntegrateFire(v_thresh=1.0, v_reset=0.0, v=0.0, a=0.0, beta=0.0174, tau_mem=20.0, tau_refrac=None, tau_adapt=2000.0, relative_reset=True, integrate_during_refrac=True, readout=None)
Bases:
Neuron
A leaky-integrate and fire neuron with an adaptive firing threshold as described by [Bellec2018].
- Parameters:
v_thresh (InitValue) – Membrane voltage firing threshold
v_reset (InitValue) – After a spike is emitted, this value is subtracted from the membrane voltage
v
ifrelative_reset
isTrue
. Otherwise, ifrelative_reset
isFalse
, the membrane voltage is set to this value.v (InitValue) – Initial value of membrane voltage
a (InitValue) – Initial value of adaptation
beta (InitValue) – Strength of adaptation
tau_mem (InitValue) – Time constant of membrane voltage [ms]
tau_refrac (InitValue) – Duration of refractory period [ms]
tau_adapt (InitValue) – Time constant of adaptation [ms]
relative_reset (bool) – How is
v
reset after a spike?integrate_during_refrac (bool) – Should
v
continue to integrate inputs during refractory period?readout – Type of readout to attach to this neuron’s output variable
- get_model(population, dt, batch_size)
Gets PyGeNN implementation of neuron model
- Parameters:
population (Population) – Population this neuron is to be attached to
dt (float) – Timestep of simulation (in ms)
batch_size (int) – Batch size of the model
- Return type:
- class ml_genn.neurons.BinarySpikeInput(signed_spikes=False, input_frames=1, input_frame_timesteps=1)
Bases:
Neuron
,InputBase
Input neuron which simply emits a spike if the input is greater than zero. Optionally, it can also emit a ‘negative’ spike if input is less than zero.
- Parameters:
signed_spikes – Should negative spikes be emitted if input is less than zero?
input_frames – How many frames does each input have?
input_frame_timesteps – How many timesteps should each frame of input be presented for?
- get_model(population, dt, batch_size)
Gets PyGeNN implementation of neuron model
- Parameters:
population (Population) – Population this neuron is to be attached to
dt (float) – Timestep of simulation (in ms)
batch_size (int) – Batch size of the model
- Return type:
- class ml_genn.neurons.FewSpikeRelu(k=10, alpha=25, readout=None)
Bases:
Neuron
A few-spike neuron to encode a ReLU ANN activation as described by [Stockl2021].
Should typically be created by converting an ANN to an SNN using
ml_genn_tf.converters.FewSpike
.- Parameters:
k (int) – Number of timesteps to encode activation over.
alpha (float) – Scaling factor to apply to activations.
readout – Type of readout to attach to this neuron’s output variable
- get_model(population, dt, batch_size)
Gets PyGeNN implementation of neuron model
- Parameters:
population (Population) – Population this neuron is to be attached to
dt (float) – Timestep of simulation (in ms)
batch_size (int) – Batch size of the model
- Return type:
- pipelined = True
- class ml_genn.neurons.FewSpikeReluInput(k=10, alpha=25, signed_input=False)
Bases:
Neuron
,InputBase
A few-spike neuron to encode inputs using a ReLU activation as described by [Stockl2021].
Should typically be created by converting an ANN to an SNN using
ml_genn_tf.converters.FewSpike
.- Parameters:
k (int) – Number of timesteps to encode activation over.
alpha (float) – Scaling factor to apply to activations.
signed_input – Are inputs expected to be both positive and negative?
- get_model(population, dt, batch_size)
Gets PyGeNN implementation of neuron model
- Parameters:
population (Population) – Population this neuron is to be attached to
dt (float) – Timestep of simulation (in ms)
batch_size (int) – Batch size of the model
- Return type:
- class ml_genn.neurons.Input
Bases:
object
Base class for all types of input neuron
- abstract set_input(genn_pop, batch_size, shape, input)
Copy provided data to GPU.
- Parameters:
genn_pop – GeNN
NeuronGroup
object population has been compiled intobatch_size (int) – Batch size of compiled network
shape – Shape of input population
input – Input data
- class ml_genn.neurons.IntegrateFire(v_thresh=1.0, v_reset=0.0, v=0.0, readout=None, **kwargs)
Bases:
Neuron
An integrate and fire neuron.
- Parameters:
v_thresh (InitValue) – Membrane voltage firing threshold
v_reset (InitValue) – After a spike is emitted, the membrane voltage is set to this value.
v (InitValue) – Initial value of membrane voltage
readout – Type of readout to attach to this neuron’s output variable
- get_model(population, dt, batch_size)
Gets PyGeNN implementation of neuron model
- Parameters:
population (Population) – Population this neuron is to be attached to
dt (float) – Timestep of simulation (in ms)
batch_size (int) – Batch size of the model
- Return type:
- class ml_genn.neurons.IntegrateFireInput(v_thresh=1.0, v_reset=0.0, v=0.0, input_frames=1, input_frame_timesteps=1)
Bases:
IntegrateFire
,InputBase
An integrate and fire input neuron.
- Parameters:
v_thresh (InitValue) – Membrane voltage firing threshold
v_reset (InitValue) – After a spike is emitted, the membrane voltage is set to this value.
v (InitValue) – Initial value of membrane voltage
input_frames – How many frames does each input have?
input_frame_timesteps – How many timesteps should each frame of input be presented for?
- get_model(population, dt, batch_size)
Gets PyGeNN implementation of neuron model
- Parameters:
population (Population) – Population this neuron is to be attached to
dt (float) – Timestep of simulation (in ms)
batch_size (int) – Batch size of the model
- Return type:
- class ml_genn.neurons.LeakyIntegrate(v=0.0, bias=0.0, tau_mem=20.0, scale_i=False, readout=None)
Bases:
Neuron
A leaky-integrator, typically used as an output neuron
- Parameters:
v (InitValue) – Initial value of membrane voltage
bias (InitValue) – Initial value of bias curremt
tau_mem (InitValue) – Time constant of membrane voltage [ms]
scale_i (bool) – Should input current
x
be scaled by \(1-e^\frac{-dt}{\tau_\text{mem}}\)?readout – Type of readout to attach to this neuron’s output variable
- get_model(population, dt, batch_size)
Gets PyGeNN implementation of neuron model
- Parameters:
population (Population) – Population this neuron is to be attached to
dt (float) – Timestep of simulation (in ms)
batch_size (int) – Batch size of the model
- Return type:
- class ml_genn.neurons.LeakyIntegrateFire(v_thresh=1.0, v_reset=0.0, v=0.0, tau_mem=20.0, tau_refrac=None, relative_reset=True, integrate_during_refrac=True, scale_i=False, readout=None, **kwargs)
Bases:
Neuron
A leaky-integrate and fire neuron.
- Parameters:
v_thresh (InitValue) – Membrane voltage firing threshold
v_reset (InitValue) – After a spike is emitted, this value is subtracted from the membrane voltage
v
ifrelative_reset
isTrue
. Otherwise, ifrelative_reset
isFalse
, the membrane voltage is set to this value.v (InitValue) – Initial value of membrane voltage
tau_mem (InitValue) – Time constant of membrane voltage [ms]
tau_refrac (InitValue) – Duration of refractory period [ms]
relative_reset (bool) – How is
v
reset after a spike?integrate_during_refrac (bool) – Should
v
continue to integrate inputs during refractory period?readout – Type of readout to attach to this neuron’s output variable
scale_i (bool)
- get_model(population, dt, batch_size)
Gets PyGeNN implementation of neuron model
- Parameters:
population (Population) – Population this neuron is to be attached to
dt (float) – Timestep of simulation (in ms)
batch_size (int) – Batch size of the model
- Return type:
- class ml_genn.neurons.LeakyIntegrateFireInput(v_thresh=1.0, v_reset=0.0, v=0.0, tau_mem=20.0, tau_refrac=None, relative_reset=True, integrate_during_refrac=True, scale_i=False, input_frames=1, input_frame_timesteps=1)
Bases:
LeakyIntegrateFire
,InputBase
A leaky-integrate and fire input neuron.
- Parameters:
v_thresh (InitValue) – Membrane voltage firing threshold
v_reset (InitValue) – After a spike is emitted, this value is subtracted from the membrane voltage
v
ifrelative_reset
isTrue
. Otherwise, ifrelative_reset
isFalse
, the membrane voltage is set to this value.v (InitValue) – Initial value of membrane voltage
tau_mem (InitValue) – Time constant of membrane voltage [ms]
tau_refrac (InitValue) – Duration of refractory period [ms]
relative_reset (bool) – How is
v
reset after a spike?integrate_during_refrac (bool) – Should
v
continue to integrate inputs during refractory period?input_frames – How many frames does each input have?
input_frame_timesteps – How many timesteps should each frame of input be presented for?
scale_i (bool)
- get_model(population, dt, batch_size)
Gets PyGeNN implementation of neuron model
- Parameters:
population (Population) – Population this neuron is to be attached to
dt (float) – Timestep of simulation (in ms)
batch_size (int) – Batch size of the model
- Return type:
- class ml_genn.neurons.Neuron(readout=None, **kwargs)
Bases:
ABC
Base class for all neuron models
- Variables:
readout – Type of readout to attach to this neuron’s output variable
- Parameters:
readout (Optional[Readout])
- abstract get_model(population, dt, batch_size)
Gets PyGeNN implementation of neuron model
- Parameters:
population (Population) – Population this neuron is to be attached to
dt (float) – Timestep of simulation (in ms)
batch_size (int) – Batch size of the model
- Return type:
- get_readout(genn_pop, batch_size, shape)
Use readout object associated with neuon to read output from PyGeNN neuron group into numpy array
- Parameters:
genn_pop – PyGeNN neuron group
batch_size (int) – Batch size of compiled model
shape – Shape of population
- Return type:
ndarray
- property readout
Optional object which can be used to provide a readout from neuron
Can be specified as either a Readout object or, for built in readout models whose constructors require no arguments, a string e.g. “spike_count”
- class ml_genn.neurons.PoissonInput(signed_spikes=False, input_frames=1, input_frame_timesteps=1)
Bases:
Neuron
,InputBase
Input neuron which generates spikes using a Poisson process whose rate is proportional to the magnitude of the input.
- Parameters:
signed_spikes – Should negative spikes be emitted if input is less than zero?
input_frames – How many frames does each input have?
input_frame_timesteps – How many timesteps should each frame of input be presented for?
- get_model(population, dt, batch_size)
Gets PyGeNN implementation of neuron model
- Parameters:
population (Population) – Population this neuron is to be attached to
dt (float) – Timestep of simulation (in ms)
batch_size (int) – Batch size of the model
- Return type:
- class ml_genn.neurons.SpikeInput(max_spikes=1000000)
-
An input neuron which emits spike trains provided as
ml_genn.utils.data.PreprocessedSpikes
objects- Parameters:
max_spikes – Maximum total number of spikes this population can emit for any example. This needs to include batch size i.e. if batch size is 32 and there are 100 neurons in the population, each of which emits a maximum of one spike per example, \(\text{max_spikes} = 32 * 100 * 1 = 3200\)
- get_model(population, dt, batch_size)
Gets PyGeNN implementation of neuron model
- Parameters:
population (Population) – Population this neuron is to be attached to
dt (float) – Timestep of simulation (in ms)
batch_size (int) – Batch size of the model
- Return type:
- set_input(genn_pop, batch_size, shape, input)
Copy provided data to GPU.
- Parameters:
genn_pop – GeNN
NeuronGroup
object population has been compiled intobatch_size (int) – Batch size of compiled network
shape – Shape of input population
input (PreprocessedSpikes | Sequence[PreprocessedSpikes]) – Input data