SNN

Spiking neural networks

class spikelearn.snn.SpikingNet

A class implementing arbitrary neural networks

Imstances start with empty networks, which can be subsequently populated with layers, inputs, and synapses

  • Layers are objects taking a one or more inputs and returning an output. They should implement the methods __call__ and reset and an attribute out that preserves the results from the last computation.

  • Inputs define external inputs whose values are passed to the network through the __call__ method.

  • Synapses connect one or more presynaptic layers with a postsynaptic layer. They should implement the methods __call__, reset, and update. The update method should be able to take two arguments, one representing the activity of the postsynaptic neuron and an optional flag that triggers learning if it is an active synapse.

A network can be constructed using a series of method that help define inputs, outputs, layers, and the synapses connecting them. The construction of the network is meant to be a one-off process. Deleting layers or synapses would most likely break the network or result in unpredictable behavior.

add_layer(snl, name)

Adds a layer to the snn

Parameters
  • snl – a layer of neurons

  • name – the name of the layer

add_synapse(pos_name, syn, *pre_names)

Adds a synapse between two or more network nodes

A synapse has only one postsynaptic connection but can have more than one presynaptic connection to include the case of ternary synapses involving one or more modulatory inputs.

Parameters
  • pos_name – name of the postsynaptic layer

  • syn – a synapse object

  • pre_names – names of one or more presynaptic layers

Raises

ValueError – pre or postsynaptic connection not identified.

reset()

Resets all elements of the network

Broadcasts a reset signal to all nodes and synapses in the network

Neurons

Neurons in Spikingnet are grouped in layers.

All neurons share the same underlying interface, with Spikingnet expecting neurons to be callable and have reset and update methods defined.

class spikelearn.neurons.SpikingLayer(N, tau, v0=1, refr=True)

Implements a leaky integrate and fire

Implements a layer of LIF neurons. Its interface conforms to that of a Layer object.

out

array containing last activations

N

number of neurons in the layer

v

array with membrane potential

s

array with neuron activations

tau

decay time, in timestep units

reset()

Resets the neuron internal state

step(*x)

Advances the neuron a single timestep

class spikelearn.neurons.SpikingRecLayer(N, tau, Wrec, v0=1)

Implements spiking neurons with an internal recurrent interaction.

Implements a layer of leaky integrate and fire (LIF) neurons with an additional static, recurrent interaction within the layer. This layer can be used to implement cross-inhibition between neurons within the layer. Its interface conforms to that of a Layer object.

out

array containing last activations

N

number of neurons in the layer

v

array with membrane potential

s

array with neuron activations

tau

decay time, in timestep units

Wrec

recurrent synaptic weights

spikelearn.neurons.hard(x)

Implements a Heaviside or step function

Parameters

x – a numpy array object

Returns

1 if x>0, 0 otherwise

Return type

An array

Synapses

Implement static and plastic synapses

A synapse object should implement three methods:

  • A __call__ method taking an arbitrary number of inputs and returning the synapse output

  • An update(xo) method that passes the output of the neurons

  • A reset() method

Update and reset can be dummies, but a SpikingNet expects that they will be implemented.

class spikelearn.synapses.BaseSynapse(Ne, No, W0, transform=None, syn_type=None)

Static synapse, where synaptic weights are stored in a 2D array.

class spikelearn.synapses.MSESynapse(Ne, No, W0, tre, tro, trm, transform=None, transform_mod=None, rule_params=None, Wlim=1, syn_type=None, tracelim=10)

Simple plastic synapse implementing non-hebbian MSE rule

class spikelearn.synapses.ModSTDPSynapse(Ne, No, W0, tre, tro, trm, transform=None, transform_mod=None, rule_params=None, Wlim=1, syn_type=None, tracelim=10)
class spikelearn.synapses.OneToOneSynapse(Ne, W0, transform=None, syn_type=None)

One to one static synapse

Implement one to one static synapse chaining each input to its corresponding output.

class spikelearn.synapses.PlasticSynapse(Ne, No, W0, tre, tro, transform=None, rule_params=None, Wlim=1, syn_type=None, tracelim=10)

Simple plastic synapse implementing STDP

spikelearn.synapses.STDPSynapse

alias of PlasticSynapse

spikelearn.synapses.StaticSynapse

alias of BaseSynapse

class spikelearn.synapses.TernarySynapse(Ne, No, W0, tre, tro, trm, transform=None, transform_mod=None, rule_params=None, Wlim=1, syn_type=None, tracelim=10)

Simple plastic synapse implementing modulated STDP