superneuromat.Neuron#
- class superneuromat.Neuron(model: SNN, idx: int)[source]#
Accessor Class for Neurons in SNNs
Warning
Instances of Neurons are created at access time and are not unique. Multiple instances of this class may be created for the same neuron on the SNN. To test for equality, use
==
instead ofis
.- Attributes:
leak
The amount by which the internal state of this neuron is pushed towards its reset state.
refractory_period
The number of time steps for which this neuron should be in its refractory period.
refractory_state
The remaining number of time steps for which this neuron is in its refractory period.
reset_state
The charge state of this neuron immediately after spiking.
spikes
A vector of the spikes that have been emitted by this neuron.
state
The charge state of this neuron.
threshold
The > threshold value for this neuron to spike.
Methods
add_spike
(time[, value])Queue a spike to be sent to this Neuron.
add_spikes
(spikes[, time_offset, exist])Add a time-series of spikes to this neuron.
connect_child
(child[, weight, delay, ...])Connect this neuron to a child neuron.
connect_parent
(parent[, weight, delay, ...])Connect this neuron to a parent neuron.
info
()Returns a string containing information about this neuron.
info_row
()Returns a string containing information about this neuron for use in a table.
spikes_str
([max_steps, use_unicode])Returns a pretty string of the spikes that have been emitted by this neuron.
row_cont
row_header
- add_spike(time: int, value: float = 1.0, **kwargs)[source]#
Queue a spike to be sent to this Neuron.
- add_spikes(spikes: list[float] | list[tuple[int, float]] | ~numpy.ndarray[(<class 'int'>,), ~numpy.dtype] | ~numpy.ndarray[(<class 'int'>, 2), ~numpy.dtype], time_offset: int = 0, exist: str = 'error')[source]#
Add a time-series of spikes to this neuron.
- Parameters:
Examples
If the input is a list of floats, it will be interpreted as a time-series of spikes to be fed in, one after the other.
neuron.add_spikes([0.0, 1.0, 2.0, 3.0]) # is equivalent to for i in range(4): neuron.add_spike(i, i)
However,
0.0
-valued spikes are not added unlessexist='overwrite'
.If you would like to send a set of spikes at particular times, you can use a list of tuples:
neuron.add_spikes([ (1, 1.0), (3, 3.0), ])
Note
The times and values will be cast to
SNN.default_dtype
.See also
Changed in version v3.2.0: Returns the
Synapse
object created.
- connect_child(child, weight: float = 1.0, delay: int = 1, stdp_enabled: bool = False, exist='error') Synapse [source]#
Connect this neuron to a child neuron.
- Parameters:
child (Neuron | int) – The child neuron that will receive the spikes from this neuron.
weight (float, default=1.0) – The weight of the synapse connecting this neuron to the child.
delay (int, default=1) – The delay of the synapse connecting this neuron to the child.
stdp_enabled (bool, default=False) – If
True
, enable STDP learning on the synapse connecting this neuron to the child.
- Returns:
Synapse
.. seealso:: –
Neuron.connect_parent()
SNN.create_synapse()
.. versionchanged:: v3.2.0 – Returns the
Synapse
object created.
- connect_parent(parent, weight: float = 1.0, delay: int = 1, stdp_enabled: bool = False, exist='error') Synapse [source]#
Connect this neuron to a parent neuron.
- Parameters:
parent (Neuron | int) – The parent neuron that will send spikes to this neuron.
weight (float, default=1.0) – The weight of the synapse connecting the parent to this neuron.
delay (int, default=1) – The delay of the synapse connecting the parent to this neuron.
stdp_enabled (bool, default=False) – If
True
, enable STDP learning on the synapse connecting the parent to this neuron.
- Returns:
Synapse
.. seealso:: –
Neuron.connect_child()
SNN.create_synapse()
- info()[source]#
Returns a string containing information about this neuron.
The order of the fields is the same as in
SNN.neuron_info()
but without the spikes column.
- info_row()[source]#
Returns a string containing information about this neuron for use in a table.
This function is used to generate rows for
SNN.neuron_info()
.
- property leak: float[source]#
The amount by which the internal state of this neuron is pushed towards its reset state.
- property refractory_period: int[source]#
The number of time steps for which this neuron should be in its refractory period.
- property refractory_state: float[source]#
The remaining number of time steps for which this neuron is in its refractory period.
- property spikes: bool]] | list[source]#
A vector of the spikes that have been emitted by this neuron.