Migrating from older versions of SuperNeuroMAT#

This page describes the necessary changes to migrate your code from SuperNeuroMAT v1.x.x to the latest version, v3.2.1.

Only breaking changes are covered on this page.

For more information on the changes, see the GitHub release notes: ORNL/superneuromat.

2.0.x to 3.x.x#

Remove calls to SNN.setup().

Outside of manual setup mode, SNN.setup() will now raise a warning, as SNN.simulate() now sets up the SNN automatically.

If you need to manually setup the SNN, see Manual Setup.

Remove time_steps parameter from SNN.stdp_setup().

SNN.stdp_setup() no longer accepts a time_steps parameter.

Simply remove the time_steps parameter from the call. The number of STDP time steps will be inferred from the length of the apos and aneg lists. However, if both positive and negative updates are enabled, you must still keep both lists the same length.

snn.stdp_setup(
   # time_steps=3,  # remove this
   Apos=[1.0, 0.5, 0.25],
   Aneg=[-0.1, -0.05, -0.025],
)
Add .idx when assigning SNN.create_neuron and SNN.create_synapse.

SNN.create_neuron() and SNN.create_synapse() now return a Neuron or Synapse object.

Previously, SNN.create_neuron() and SNN.create_synapse() returned the id of the created neuron or synapse as an int.

In v3, Neuron and Synapse classes were added. These allow for easier manipulation of the SNN, and now SNN.create_neuron() and SNN.create_synapse() return these object instances upon creation.

However, the id of the created neuron or synapse can still be easily retrieved with the Neuron.idx and Synapse.idx attributes.

neuron_id = snn.create_neuron().idx
synapse_id = snn.create_synapse(neuron_id, neuron_id).idx
Make all elements of aneg negative in SNN.stdp_setup().

The STDP SNN.aneg parameter now expects a list of negative values to result in the same behavior as stdp_setup(aneg) in v1.x.x.

i.e. Change aneg=[1.0] to aneg=[-1.0].

aneg represents the post-excitatory response. In SuperNeuroMAT, synapses which do not see a causal link (pre-synaptic neuron fires, then post-synaptic neuron fires) typically results in a negative (inhibitory) update to the weight of that synapse. However, this change was made to allow for positive weight updates in this situation. You will now receive a warning if you use aneg with a negative value, but this can be turned off with the SNN.allow_incorrect_stdp_sign parameter or SNMAT_ALLOW_INCORRECT_STDP_SIGN environment variable.

Use snn.ispikes.sum() instead of snn.num_spikes.

The SNN.num_spikes attribute has been removed.

See SNN.ispikes and Decoding Recipes.

Restoring weights requires memoization before SNN.reset().

Previously, on SNN.reset(), the weights of the network would be restored to the values they were set to at synapse creation time. This behavior has changed.

If you want to restore the weights of a network, you must first memoize them. See Resetting the SNN and Managing SNN State. This system allows for more flexibility in when the weights are stored and recalled.

1.x.x to 2.0.x#

NeuromorphicModel() is now SNN().

You should now use snn = SNN() to create a new SNN.

Old#
from superneuromat import NeuromorphicModel
snn = NeuromorphicModel()

# even older installations may have used
from superneuromat.neuromorphicmodel import NeuromorphicModel
New#
from superneuromat import SNN
snn = SNN()

# or
import superneuromat as snm
snn = snm.SNN()

Change the enable_stdp parameter to stdp_enabled in SNN.create_synapse().

pip install superneuromat or update your PYTHONPATH.

Using path hacks to import SuperNeuroMAT is deprecated. Instead, you should use a pip editable install, and we recommend installing this in a virtual environment: Downloading & Installing as editable.

However, it may still be possible to add your local copy of SuperNeuroMAT to your PYTHONPATH environment variable. This is not recommended, as it may cause conflicts with other packages.

Please be aware that the path to the package has changed. The SuperNeuroMAT project now uses a src layout rather than a flat layout.

This means that the path to the package changed from:

superneuromat/

to:

superneuromat/src/superneuromat

See src layout vs flat layout for more information.