Spiking neural networks¶
Spiking neural networks are instantiated using the SpikingNet
class. A SpikeNet contains layers, synapses, and inputs.
- class spikelearn.snn.SpikingNet¶
A class implementing arbitrary neural networks
Instances 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.
- __call__(*args, learn=True)¶
Advances the network a single timestep.
- Parameters:
args – a tuple of inputs. Must match the number of inputs in the SpikingNet object
learn – if True, broadcasts a learn signal at the end of the timestep
- Returns:
A list with the declared network outputs
- add_input(name)¶
Adds an external input
- Parameters:
name – the name of the input
- Raises:
ValueError – User tries to reuse an existing name
- add_layer(snl, name)¶
Adds a layer to the snn
- Parameters:
snl – a layer of neurons
name – the name of the layer
- add_output(name, n=1)¶
Defines an output
- Parameters:
name – name of the layer
n – index of the element output to be returned (optional, default 1)
- 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()¶
Broadcasts a reset signal to all layers and synapses in the network
- update(learn)¶
Broadcasts a learn signal to all layers and synapses