superneuromat.Neuron#
- class superneuromat.Neuron(snn=<object object>, idx: int = <object object>, *args, **kwargs)[source]#
Accessor Class for Neurons in SNNs
Warning
Instances of Neurons are cached at access time as of v3.4.0. i.e.
snn.neurons[0] is snn.neurons[0]. Prior to v3.4.0, new Neuron instances were created on each access.- Attributes:
attributes_dictReturn a dictionary of the attributes of this neuron.
child_idsReturns a list of the IDs of the child neurons of this neuron.
childrenReturns a list of the child neurons of this neuron.
incoming_synapsesReturns a list of the synapses that have this neuron as their post-synaptic neuron.
incoming_synaptic_idsReturns a list of the synaptic ids of the synapses that have this neuron as their post-synaptic neuron.
leakThe amount by which the internal state of this neuron is pushed towards its reset state.
mThe
SNNthat this object is associated with.num_onmodelThe number of neurons in the SNN.
outgoing_synapsesReturns a list of the synapses that have this neuron as their pre-synaptic neuron.
outgoing_synaptic_idsReturns a list of the synaptic ids of the synapses that have this neuron as their pre-synaptic neuron.
parent_idsReturns a list of the IDs of the parent neurons of this neuron.
parentsReturns a list of the parent neurons of this neuron.
refractory_periodThe number of time steps for which this neuron should be in its refractory period.
refractory_stateThe remaining number of time steps for which this neuron is in its refractory period.
reset_stateThe charge state of this neuron immediately after spiking.
spikesA vector of the spikes that have been emitted by this neuron.
stateThe charge state of this neuron.
thresholdThe > threshold value for this neuron to spike.
Methods
Sets the refractory period countdown for this neuron to the post-fire state.
Sets the charge state of this neuron to the reset (post-fire) state.
add_spike(time[, value])Queue a spike to be sent to this Neuron.
add_spikes(spikes, ...)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.
get_synapse_from(neuron)Returns the synapse connecting the given neuron to this neuron (directional).
get_synapse_to(neuron)Returns the synapse connecting this neuron to the given neuron (directional).
get_synaptic_id_from(neuron)Returns the synaptic id of the synapse connecting the given neuron to this neuron (directional).
get_synaptic_id_to(neuron)Returns the synaptic id of the synapse connecting this neuron to the given neuron (directional).
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.
Sets the refractory period countdown for this neuron to zero.
Sets the charge state of this neuron to zero.
row_cont
row_header
- activate_refractory_period()[source]#
Sets the refractory period countdown for this neuron to the post-fire state.
- 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
Synapseobject created.
- attribute_names = ['state', 'threshold', 'leak', 'reset_state', 'refractory_state', 'refractory_period'][source]#
A list of attributes to include in
Neuron.attributes_dict().
- property attributes_dict[source]#
Return a dictionary of the attributes of this neuron. The included attributes are controlled by
Neuron.attribute_names.
- property child_ids: list[int][source]#
Returns a list of the IDs of the child neurons of this neuron.
- 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
Synapseobject 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()
- get_synapse_from(neuron: int | Neuron) Synapse[source]#
Returns the synapse connecting the given neuron to this neuron (directional).
- Parameters:
neuron (Neuron | int) – The neuron which sends spikes to this neuron.
- Returns:
The synapse connecting the given neuron to this neuron.
- Return type:
- Raises:
TypeError – If neuron is not a Neuron or neuron ID (int).
IndexError – If no matching synapse is found.
- get_synapse_to(neuron: int | Neuron) Synapse[source]#
Returns the synapse connecting this neuron to the given neuron (directional).
- Parameters:
neuron (Neuron | int) – The neuron to which this neuron is connected.
- Returns:
The synapse connecting this neuron to the given neuron.
- Return type:
- Raises:
TypeError – If neuron is not a Neuron or neuron ID (int).
IndexError – If no matching synapse is found.
- get_synaptic_id_from(neuron: int | Neuron) int | None[source]#
Returns the synaptic id of the synapse connecting the given neuron to this neuron (directional).
- get_synaptic_id_to(neuron: int | Neuron) int | None[source]#
Returns the synaptic id of the synapse connecting this neuron to the given neuron (directional).
- Parameters:
neuron (Neuron | int) – The neuron to which this neuron is connected.
- Returns:
The synaptic id of the synapse connecting this neuron to the given neuron.
- Return type:
int | None
- Raises:
TypeError – If neuron is not a Neuron or neuron ID (int).
IndexError – If no matching synapse is found.
- property incoming_synapses: list[Synapse][source]#
Returns a list of the synapses that have this neuron as their post-synaptic neuron.
- property incoming_synaptic_ids: list[int][source]#
Returns a list of the synaptic ids of the synapses that have this neuron as their post-synaptic neuron.
- 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 outgoing_synapses: list[Synapse][source]#
Returns a list of the synapses that have this neuron as their pre-synaptic neuron.
- property outgoing_synaptic_ids: list[int][source]#
Returns a list of the synaptic ids of the synapses that have this neuron as their pre-synaptic neuron.
- property parent_ids: list[int][source]#
Returns a list of the IDs of the parent neurons of this neuron.
- 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.