sns_toolbox.networks
Networks store neuron and synapse types, and the pattern of connections between them. While not capable of being simulated directly, they are used as a template for compilation.
Classes
Base class for all Networks. |
|
Network which performs addition or subtraction of multiple inputs. Currently only supports non-spiking neurons. |
|
Network where the activity in neuron 0 is roughly multiplied by the activity in neuron 1. Currently only supports |
|
Network where the activity in neuron 0 is roughly divided by the activity in neuron 1. Currently only supports |
|
Network where the activity of 'Uout' is the derivative of the activity in 'Uin'. Currently only supports |
|
Network where the activity of 'Uint' integrates the applied stimulus to itself over time. Currently only supports |
Functions
|
Generate a connection matrix from a kernel vector and population size. |
|
Generate a connection matrix from a kernel matrix and population shape. |
Module Contents
- class sns_toolbox.networks.Network(name: str = 'Network')
Base class for all Networks.
- Parameters:
name (str, optional) – Name for this network, defaults to ‘Network”.
- params: Dict[str, Any]
- inputs = []
- populations = []
- outputs = []
- outputConns = []
- connections = []
- get_num_neurons() int
Calculate the number of neurons in the network, including within populations.
- Returns:
The number of neurons in the network.
- Return type:
int
- get_num_connections() int
Calculate the number of connections in the network. Does not account for individual synapses between neurons in populations.
- Returns:
The number of connections in the network.
- Return type:
int
- get_num_populations() int
Get the number of populations in the network.
- Returns:
Number of populations.
- Return type:
int
- get_num_inputs() int
Get the number of input nodes to the network. Vector inputs are treated as a single input node.
- Returns:
Number of inputs.
- Return type:
int
- get_num_inputs_actual() int
Calculate the number of individual inputs throughout the network. Vector inputs have one input per dimension.
- Returns:
Number of individual inputs.
- Return type:
int
- get_num_outputs() int
Get the number of output nodes from the network. Vector outputs have one output node.
- Returns:
Number of outputs.
- Return type:
int
- get_num_outputs_actual() int
Calculate the number of individual outputs from the network. Vector outputs have one output per dimension.
- Returns:
Number of individual outputs.
- Return type:
int
- get_population_index(name: str) int
Given a string, find the numerical index of the population corresponding to that name within the network.
- Parameters:
name (str) – Name of the population to find.
- Returns:
Index of the population.
- Return type:
int
- get_connection_index(name: str) int
Given a string, find the numerical index of the connection corresponding to that name within the network.
- Parameters:
name (str) – Name of the connection to find.
- Returns:
Index of the connection.
- Return type:
int
- get_input_index(name: str) int
Given a string, find the numerical index of the input node given by that name within the network.
- Parameters:
name (str) – Name of the input node to find.
- Returns:
Index of the input node.
- Return type:
int
- add_population(neuron_type: sns_toolbox.neurons.Neuron, shape, name: str = None, color=None, initial_value=None) None
Add a neural population to the network.
- Parameters:
neuron_type (sns_toolbox.design.neurons.Neuron) – Type of neuron to add.
shape (np.ndarray or torch.tensor) – The number of neurons in each dimension of the population.
name (str, optional) – Name of the population, default is the original name.
color (str, optional) – Color of the population in the rendered image, default is the original color.
initial_value (class: 'numbers.Number', class: 'np.ndarray', or class: 'torch.tensor') – Initial value of membrane voltage for each neuron in the population. Must be either a single value, or an array matching ‘shape’. Default value is the original value.
- Returns:
None
- Return type:
N/A
- add_neuron(neuron_type: sns_toolbox.neurons.Neuron, name=None, color=None, initial_value=None) None
Add a neuron to the network. Note that this is just a special case of addPopulation, which makes a population of 1 neuron.
- Parameters:
neuron_type (sns_toolbox.design.neurons.Neuron) – Type of neuron to add.
name (str, optional) – Name of the neuron, defaults to the original name.
color (str, optional) – Color of the neuron in the visual render, defaults to the original color.
initial_value (Number) – Initial value of the membrane voltage, defaults to 0.0. Units are millivolts (mV).
- Returns:
None
- Return type:
N/A
- add_input(dest: Any, size: int = 1, name: str = 'Input', color='white') None
Add an input source to the network.
- Parameters:
dest (int or string) – Destination this input connects to.
size (int, optional) – Number of input elements, default is 1.
name (str, optional) – Name of the input node, default is ‘Input’.
color (str, optional) – Color of the input node in the visual render, default is ‘white’.
- Returns:
None
- Return type:
N/A
- add_output(source: Any, name: str = 'Output', spiking: bool = False, color: str = 'white') None
Add an output node to the network.
- Parameters:
source (int or str) – Source this output is connected to.
name (str, optional) – Name of the node, defaults to ‘Output’.
spiking (bool, optional) – Flag for if this node stores voltage or spikes, default is ‘False’.
color (str, optional) – Color of the output in the visual render, default is ‘white’.
- Returns:
None
- Return type:
N/A
- add_connection(connection_type: sns_toolbox.connections.Connection, source: Any, destination: Any, name: str = None, view_label: bool = False) None
Add a synaptic connection between two populations in the network.
- Parameters:
connection_type (sns_toolbox.design.connections.Connection) – Type of connection to add.
source (int or str) – Index or name of source population in the network.
destination (int or str) – Index or name of destination population in the network.
name (str, optional) – Name of synapse, default is the original name.
view_label (bool, optional) – Flag to render the name on the output graph, default is ‘False’.
- Returns:
None
- Return type:
N/A
- add_network(network: Network, color: str = None, suffix: str = None) None
Add an existing topology of inputs, outputs, and populations to the network.
- Parameters:
network (sns_toolbox.design.networks.Network) – Network to copy over.
color (str, optional) – Color to render nodes in the network, default is the original colors.
suffix (str, optional) – String to append to all the population/neuron names in the network.
- Returns:
None
- Return type:
N/A
- copy()
Create a copy of the network.
- Returns:
A new network with the same properties as the original. Each can be edited without effecting the other.
- Return type:
sns_toolbox.design.networks.Network
- compile(dt=0.01, backend='numpy', device='cpu', debug=False, return_params=False) sns_toolbox.backends.Backend
- sns_toolbox.networks.__kernel_connections_1d__(pop_size, kernel, fill_value=0.0)
Generate a connection matrix from a kernel vector and population size.
- Parameters:
pop_size (int) – Number of neurons in the population.
kernel (list, np.ndarray, or torch.tensor) – Kernel vector to apply.
- Returns:
Connection matrix.
- Return type:
np.ndarray
- sns_toolbox.networks.__kernel_connections_2d__(pop_shape, kernel, fill_value=0.0)
Generate a connection matrix from a kernel matrix and population shape.
- Parameters:
pop_shape (list, np.ndarray, or torch.tensor) – Shape of the population.
kernel (np.ndarray or torch.Tensor) – Kernel matrix to apply.
- Returns:
Connection matrix.
- Return type:
np.ndarray
- class sns_toolbox.networks.AdditionNetwork(gains, add_del_e=100, sub_del_e=-40, neuron_type=NonSpikingNeuron(), name='Add', R=20.0, **kwargs)
Bases:
Network
Network which performs addition or subtraction of multiple inputs. Currently only supports non-spiking neurons.
- Parameters:
gains (list, np.ndarray, or torch.tensor) – List of addition or subtraction weights.
add_del_e (Number, optional) – Reversal potential of addition synapses, default is 100. Unit is millivolts (mV).
sub_del_e (Number, optional) – Reversal potential of subtraction synapses, default is -40. Unit is millivolts (mV).
neuron_type (sns_toolbox.design.neurons.NonSpikingNeuron, optional) – Neuron preset to use, default is sns_toolbox.design.neurons.NonSpikingNeuron.
name (str, optional) – Name of this network, default is ‘Add’.
- num_inputs
- class sns_toolbox.networks.MultiplicationNetwork(neuron_type=NonSpikingNeuron(), name='Multiply', R=20.0, **kwargs)
Bases:
Network
Network where the activity in neuron 0 is roughly multiplied by the activity in neuron 1. Currently only supports non-spiking neurons.
- Parameters:
neuron_type (sns_toolbox.design.neurons.NonSpikingNeuron, optional) – Neuron preset to use, default is sns_toolbox.design.neurons.NonSpikingNeuron.
name (str, optional) – Name of this network, default is ‘Multiply’.
- transmit
- conductance
- modulate_special
- class sns_toolbox.networks.DivisionNetwork(gain, ratio, name='Divide', neuron_type=NonSpikingNeuron(), R=20.0, **kwargs)
Bases:
Network
Network where the activity in neuron 0 is roughly divided by the activity in neuron 1. Currently only supports non-spiking neurons.
- Parameters:
neuron_type (sns_toolbox.design.neurons.NonSpikingNeuron, optional) – Neuron preset to use, default is sns_toolbox.design.neurons.NonSpikingNeuron.
ratio (Number) – Modulation ratio.
name (str, optional) – Name of this network, default is ‘Divide’.
- transmission
- modulation
- class sns_toolbox.networks.DifferentiatorNetwork(slew_rate=1.0, name='Differentiate', tau_fast=1.0, R=20.0, **kwargs)
Bases:
Network
Network where the activity of ‘Uout’ is the derivative of the activity in ‘Uin’. Currently only supports non-spiking neurons.
- Parameters:
slew_rate (Number, optional) – Steepest signal this differentiator can handle, default is 1.0. Influences the difference in internal time constants.
name (str, optional) – Name of this network, default is ‘Differentiate’.
tau_fast (Number, optional) – Time constant of the faster neurons, default is 1.0. Units are milliseconds (ms).
- fast_neuron_type
- tau_slow
- slow_neuron_type
- add_synapse
- sub_synapse
- class sns_toolbox.networks.IntegratorNetwork(integration_gain=0.1, relative_reversal_potential=-40.0, R=20.0, name='Integrator', **kwargs)
Bases:
Network
Network where the activity of ‘Uint’ integrates the applied stimulus to itself over time. Currently only supports non-spiking neurons.
- Parameters:
integration_gain (Number, optional) – Gain of the integration, default is 1.0.
relative_reversal_potential (Number, optional) – Reversal potential of the synapses in the network, default is -40.0. Must be less than 0. Units are millivolts (mV).
name (str, optional) – Name of this network, default is ‘Integrator’.
- membrane_capacitance
- neuron_type
- synapse_type