superneuromat.SNN#

class superneuromat.SNN[source]#
Parameters:
  • num_neurons (int) – The number of neurons in the SNN.

  • neurons (NeuronList) – List of neurons in the SNN.

  • num_synapses (int) – The number of synapses in the SNN.

  • synapses (SynapseList) – List of synapses in the SNN.

  • spike_train (list) – List of output spike trains for each time step. Index by spike_train[t][neuron_id].

  • ispikes (numpy.ndarray[(int, int), bool]) – Binary numpy array of input spikes for each time step. Index by ispikes[t, neuron_id].

STDP Parameters

Parameters:
  • stdp (bool, default=True) – if stdp is False, STDP will be disabled globally.

  • apos (list, default=[]) – List of STDP parameters per time step for excitatory update of weights.

  • aneg (list, default=[]) – List of STDP parameters per time step for inhibitory update of weights.

  • stdp_positive_update (bool | Any, default=True) – If False, disable excitatory STDP update globally.

  • stdp_negative_update (bool | Any, default=True) – If False, disable inhibitory STDP update globally.

  • stdp_time_steps (int) – Number of time steps over which STDP updates will be made. This is determined from the length of apos or aneg.

Config Parameters

Parameters:
  • default_dtype (type | numpy.dtype, default=numpy.float64) – Default data type for internal numpy representation of all floating-point arrays.

  • default_bool_dtype (type | numpy.dtype, default=bool) – Default data type for internal numpy representation of stdp_enabled values and spike vectors.

  • gpu (bool) – If False, disable GPU acceleration. By default, this is True if numba.cuda.is_available().

  • manual_setup (bool, default=False) – If True, disable automatic setup of SNN when simulate() is called.

  • allow_incorrect_stdp_sign (bool, default=False) – If True, allow negative values in apos and positive values in aneg.

  • allow_signed_leak (bool, default=False) – If True, allow negative values in neuron_leaks. Normally, positive leak will result in charge decay.

  • backend (str, default='auto') – The backend to use for simulation. Can be 'auto', 'cpu', 'jit', or 'gpu'. Can be overridden on a per-simulate() basis.

  • sparse (bool | str | Any, default=False) – If True, use sparse representation of SNN. If 'auto', use sparse representation if num_neurons > 100. Sparse representation is only available using the 'cpu' backend.

  • last_used_backend (str, default=None) – The backend most recently used for simulation.

  • is_sparse (bool, default=False) – If True, the SNN is being internally represented using a sparse representation.

Data Attributes

These attributes are not intended to be modified directly by end users.

Parameters:
  • neuron_thresholds (list) – List of neuron thresholds

  • neuron_leaks (list) – List of neuron leaks defined as the amount by which the internal states of the neurons are pushed towards the neurons’ reset states

  • neuron_reset_states (list) – List of neuron reset states

  • neuron_refractory_periods (list) – List of neuron refractory periods

  • pre_synaptic_neuron_ids (list) – List of pre-synaptic neuron IDs

  • post_synaptic_neuron_ids (list) – List of post-synaptic neuron IDs

  • synaptic_weights (list) – List of synaptic weights

  • synaptic_delays (list) – List of synaptic delays

  • enable_stdp (list) – List of Boolean values denoting whether STDP learning is enabled on each synapse

  • input_spikes (dict) – Dictionary of input spikes for each time step.

Warning

Delay is implemented by adding a chain of proxy neurons.

A delay of 10 between neuron A and neuron B would add 9 proxy neurons between A and B. This may result in severe performance degradation. Consider using sparse representation or agent-based SNN simulators in networks with high delay times.

Hint

  • Leak brings the internal state of the neuron closer to the reset state.

    The leak value is the amount by which the internal state of the neuron is pushed towards its reset state.

  • Deletion of neurons may result in unexpected behavior.

  • Input spikes can have a value

  • All neurons are monitored by default

__init__()[source]#

Initialize the SNN

Methods#

SNN.__init__()

Initialize the SNN

Building the SNN

add_spike

Adds an external spike in the SNN

create_neuron

Create a neuron in the SNN.

create_synapse

Creates a synapse in the SNN

stdp_setup

Setup the Spike-Time-Dependent Plasticity (STDP) parameters

set_stdp_enabled_from_mat

set_weights_from_mat

Set the synaptic weights from a matrix.

Inspecting the SNN

get_neuron_df

Returns a DataFrame containing information about neurons.

neuron_spike_totals

Returns a vector of the number of spikes emitted from each neuron since last reset.

get_synapse

Returns the synapse that connects the given pre- and post-synaptic neurons.

get_synapse_df

Returns a DataFrame containing information about synapses.

get_synapses_by_post

Returns the synapses that connect the given post-synaptic neuron.

get_synapses_by_pre

Returns a list of synapses with the given pre-synaptic neuron.

get_synapse_id

Returns the id of the synapse connecting the given pre- and post-synaptic neurons.

get_synaptic_ids_by_post

Returns a list of synapse ids with the given post-synaptic neuron.

get_synaptic_ids_by_pre

Returns a list of synapse ids with the given pre-synaptic neuron.

get_weights_df

Returns a DataFrame containing information about synapse weights.

input_spikes_info

Generate a description of the synapses in the SNN.

get_input_spikes_df

Returns a DataFrame containing information about input spikes.

get_stdp_enabled_df

Returns a DataFrame containing information about STDP enabled synapses.

last_used_backend

Get the last-used backend for simulation.

pretty

Generates a text description of the model.

pretty_print

Pretty-prints the model.

pretty_spike_train

Returns a pretty string of the spike train.

print_spike_train

Prints the spike train.

short

Return a 1-line summary of the SNN.

neuron_info

Generate a description of the neurons in the SNN.

stdp_info

Generate a description of the current global STDP settings.

synapse_info

Generate a description of the synapses in the SNN.

stdp_enabled_mat

Create a boolean dense matrix which indicates whether STDP is enabled on each synapse.

stdp_enabled_sparse

weight_mat

Create a dense weight matrix from the synaptic weights.

weight_sparsity

weights_sparse

Create a sparse weight matrix from the synaptic weights.

Managing Model State

clear_input_spikes

clear_memos

Delete all stored copies of model variables.

clear_spike_train

consume_input_spikes

Consumes/deletes input spikes for the given number of time steps.

copy

Returns a copy of the SNN

devec

Copy the internal state variables back to the public-facing canonical representations.

memoize

Store a copy of model variable(s) to be restored later.

recommend

Recommend a backend to use based on network size and continuous sim time steps.

recommend_sparsity

release_mem

Delete internal variables created during computation.

reset

Reset the SNN's neuron states, refractory periods, spike train, and input spikes.

reset_neuron_states

reset_refractory_periods

restore

Restore model variables to their memoized states.

setup

Setup the SNN for simulation.

setup_input_spikes

simulate

Simulate the neuromorphic spiking neural network

simulate_cpu

simulate_cpu_jit

simulate_gpu

Simulate the neuromorphic circuit using the GPU backend.

unmemoize

Delete stored copies of model variables.

zero_neuron_states

zero_refractory_periods

rebuild_connection_ids

to_json

Exports the SNN to a JSON string.

saveas_json

Exports the SNN to a JSON file.

from_jsons

Update this SNN from a SuperNeuroMat JSON string.

Attributes#

Attributes

num_neurons

Returns the number of neurons in the SNN.

num_synapses

Returns the number of synapses in the SNN.

ispikes

Convert the output spike train to a dense binary numpy.ndarray.

backend

Set the backend to be used for simulation.

disable_performance_warnings

eqvars

The list of public variables which define the SNN model.

_internal_vars

NumPy representation of the internal state variables used during simulation.

is_sparse

Returns True if SNN is sparse internally.

sparse

The user-requested sparsity setting for the SNN

stdp_time_steps

Returns the number of time steps over which STDP updates will be made.

jit_threshold

gpu_threshold

sparsity_threshold