spynnaker.pyNN.models.neural_projections.connectors package

Module contents

class spynnaker.pyNN.models.neural_projections.connectors.AbstractConnector(safe=True, callback=None, verbose=False, rng=None)[source]

Bases: object

Abstract class that all PyNN Connectors extend.

Parameters:
  • safe (bool) – if True, check that weights and delays have valid values. If False, this check is skipped. (NB: SpiNNaker always checks.)
  • callback (callable) – Ignored
  • verbose (bool) –
  • rng (NumpyRNG or None) – Seeded random number generator, or None to make one when needed
NUMPY_SYNAPSES_DTYPE = [('source', 'uint32'), ('target', 'uint16'), ('weight', 'float64'), ('delay', 'float64'), ('synapse_type', 'uint8')]
connect(projection)[source]

Apply this connector to a projection.

Warning

Do not call this! SpyNNaker does not work that way.

Parameters:projection (Projection) –
Raises:SpynnakerException – Always. Method not supported; profiled out.
could_connect(_synapse_info, _pre_slice, _post_slice)[source]

Checks if a pre slice and a post slice could connect.

Typically used to determine if a Machine Edge should be created by checking that at least one of the indexes in the pre slice could over time connect to at least one of the indexes in the post slice.

Note

This method should never return a false negative, but may return a false positives

Parameters:
Return type:

bool

create_synaptic_block(pre_slices, post_slices, pre_vertex_slice, post_vertex_slice, synapse_type, synapse_info)[source]

Create a synaptic block from the data.

Parameters:
Returns:

The synaptic matrix data to go to the machine, as a Numpy array

Return type:

ndarray

get_delay_maximum(synapse_info)[source]

Get the maximum delay specified by the user in ms, or None if unbounded.

Parameters:synapse_info (SynapseInformation) – the synapse info
Return type:int or None
get_delay_minimum(synapse_info)[source]

Get the minimum delay specified by the user in ms, or None if unbounded.

Parameters:synapse_info (SynapseInformation) –
Return type:int or None
get_delay_variance(delays, synapse_info)[source]

Get the variance of the delays.

Parameters:delays (ndarray or NumpyRNG or int or float or list(int) or list(float)) –
Return type:float
get_n_connections_from_pre_vertex_maximum(post_vertex_slice, synapse_info, min_delay=None, max_delay=None)[source]
Get the maximum number of connections between those from any
neuron in the pre vertex to the neurons in the post_vertex_slice, for connections with a delay between min_delay and max_delay (inclusive) if both specified (otherwise all connections).
Parameters:
Return type:

int

get_n_connections_to_post_vertex_maximum(synapse_info)[source]
Get the maximum number of connections between those to any neuron
in the post vertex from neurons in the pre vertex.
Parameters:synapse_info (SynapseInformation) –
Return type:int
get_provenance_data(synapse_info)[source]
Parameters:synapse_info (SynapseInformation) –
Return type:iterable(ProvenanceDataItem)
get_weight_maximum(synapse_info)[source]

Get the maximum of the weights for this connection.

Parameters:synapse_info (SynapseInformation) –
Return type:float
get_weight_mean(weights, synapse_info)[source]

Get the mean of the weights.

Parameters:weights (ndarray or NumpyRNG or int or float or list(int) or list(float)) –
Return type:float
get_weight_variance(weights, synapse_info)[source]

Get the variance of the weights.

Parameters:weights (ndarray or NumpyRNG or int or float or list(int) or list(float)) –
Return type:float
safe
Return type:bool
set_projection_information(synapse_info)[source]

sets a connectors projection info :param SynapseInformation synapse_info: the synapse info

set_space(space)[source]

Set the space object (allowed after instantiation).

Parameters:space (Space) –
space

The space object (may be updated after instantiation).

Return type:Space or None
synapse_info

The synapse_info object (may be updated after instantiation).

Return type:synapse_info or None
use_direct_matrix(synapse_info)[source]
Parameters:synapse_info (SynapseInformation) –
Return type:bool
verbose
Return type:bool
class spynnaker.pyNN.models.neural_projections.connectors.AbstractGenerateConnectorOnMachine(safe=True, callback=None, verbose=False)[source]

Bases: spynnaker.pyNN.models.neural_projections.connectors.abstract_connector.AbstractConnector

Indicates that the connectivity can be generated on the machine

Parameters:
  • safe (bool) –
  • callback (callable) – Ignored
  • verbose (bool) –
gen_connector_id

The ID of the connection generator on the machine.

Return type:int
gen_connector_params(pre_slices, post_slices, pre_vertex_slice, post_vertex_slice, synapse_type, synapse_info)[source]

Get the parameters of the on machine generation.

Parameters:
Return type:

ndarray(uint32)

gen_connector_params_size_in_bytes

The size of the connector parameters in bytes.

Return type:int
gen_delay_params(delays, pre_vertex_slice, post_vertex_slice)[source]

Get the parameters of the delay generator on the machine

Parameters:
Return type:

ndarray(uint32)

gen_delay_params_size_in_bytes(delays)[source]

The size of the delay parameters in bytes

Parameters:delays (ndarray or NumpyRNG or int or float or list(int) or list(float)) –
Return type:int
gen_delays_id(delays)[source]

Get the id of the delay generator on the machine

Parameters:delays (ndarray or NumpyRNG or int or float or list(int) or list(float)) –
Return type:int
gen_weight_params_size_in_bytes(weights)[source]

The size of the weight parameters in bytes

Parameters:weights (ndarray or NumpyRNG or int or float or list(int) or list(float)) –
Return type:int
gen_weights_id(weights)[source]

Get the id of the weight generator on the machine

Parameters:weights (ndarray or NumpyRNG or int or float or list(int) or list(float)) –
Return type:int
gen_weights_params(weights, pre_vertex_slice, post_vertex_slice)[source]

Get the parameters of the weight generator on the machine

Parameters:
Return type:

ndarray(uint32)

generate_on_machine(weights, delays)[source]

Determine if this instance can generate on the machine.

Default implementation returns True if the weights and delays can be generated on the machine

Parameters:
Return type:

bool

class spynnaker.pyNN.models.neural_projections.connectors.AbstractConnectorSupportsViewsOnMachine[source]

Bases: object

Connector that generates on machine and supports using PopulationViews

N_VIEWS_PARAMS = 4
get_view_lo_hi(indexes)[source]

Get the low and high index values of the PopulationView

Parameters:indexes (list(int)) – the indexes array of a PopulationView
Returns:The low and high index values of the PopulationView
Return type:uint, uint
class spynnaker.pyNN.models.neural_projections.connectors.AllToAllConnector(allow_self_connections=True, safe=True, verbose=None, callback=None)[source]

Bases: spynnaker.pyNN.models.neural_projections.connectors.abstract_generate_connector_on_machine.AbstractGenerateConnectorOnMachine, spynnaker.pyNN.models.neural_projections.connectors.abstract_connector_supports_views_on_machine.AbstractConnectorSupportsViewsOnMachine

Connects all cells in the presynaptic population to all cells in the postsynaptic population.

Parameters:
  • allow_self_connections (bool) – if the connector is used to connect a Population to itself, this flag determines whether a neuron is allowed to connect to itself, or only to other neurons in the Population.
  • safe (bool) – If True, check that weights and delays have valid values. If False, this check is skipped.
  • verbose (bool) – Whether to output extra information about the connectivity to a CSV file
  • callback (callable) –

    if given, a callable that display a progress bar on the terminal.

    Note

    Not supported by sPyNNaker.

allow_self_connections
Return type:bool
create_synaptic_block(pre_slices, post_slices, pre_vertex_slice, post_vertex_slice, synapse_type, synapse_info)[source]

Create a synaptic block from the data.

Parameters:
Returns:

The synaptic matrix data to go to the machine, as a Numpy array

Return type:

ndarray

gen_connector_id

The ID of the connection generator on the machine.

Return type:int
gen_connector_params(pre_slices, post_slices, pre_vertex_slice, post_vertex_slice, synapse_type, synapse_info)[source]

Get the parameters of the on machine generation.

Parameters:
Return type:

ndarray(uint32)

gen_connector_params_size_in_bytes

The size of the connector parameters in bytes.

Return type:int
get_delay_maximum(synapse_info)[source]

Get the maximum delay specified by the user in ms, or None if unbounded.

Parameters:synapse_info (SynapseInformation) – the synapse info
Return type:int or None
get_delay_minimum(synapse_info)[source]

Get the minimum delay specified by the user in ms, or None if unbounded.

Parameters:synapse_info (SynapseInformation) –
Return type:int or None
get_n_connections_from_pre_vertex_maximum(post_vertex_slice, synapse_info, min_delay=None, max_delay=None)[source]
Get the maximum number of connections between those from any
neuron in the pre vertex to the neurons in the post_vertex_slice, for connections with a delay between min_delay and max_delay (inclusive) if both specified (otherwise all connections).
Parameters:
Return type:

int

get_n_connections_to_post_vertex_maximum(synapse_info)[source]
Get the maximum number of connections between those to any neuron
in the post vertex from neurons in the pre vertex.
Parameters:synapse_info (SynapseInformation) –
Return type:int
get_weight_maximum(synapse_info)[source]

Get the maximum of the weights for this connection.

Parameters:synapse_info (SynapseInformation) –
Return type:float
class spynnaker.pyNN.models.neural_projections.connectors.ArrayConnector(array, safe=True, callback=None, verbose=False)[source]

Bases: spynnaker.pyNN.models.neural_projections.connectors.abstract_connector.AbstractConnector

Make connections using an array of integers based on the IDs of the neurons in the pre- and post-populations.

Parameters:
  • array (ndarray(2, uint8)) – An explicit boolean matrix that specifies the connections between the pre- and post-populations (see PyNN documentation). Must be 2D in practice.
  • safe (bool) – Whether to check that weights and delays have valid values. If False, this check is skipped.
  • callback (callable) –

    if given, a callable that display a progress bar on the terminal.

    Note

    Not supported by sPyNNaker.

  • verbose (bool) – Whether to output extra information about the connectivity to a CSV file
create_synaptic_block(pre_slices, post_slices, pre_vertex_slice, post_vertex_slice, synapse_type, synapse_info)[source]

Create a synaptic block from the data.

Parameters:
Returns:

The synaptic matrix data to go to the machine, as a Numpy array

Return type:

ndarray

get_delay_maximum(synapse_info)[source]

Get the maximum delay specified by the user in ms, or None if unbounded.

Parameters:synapse_info (SynapseInformation) – the synapse info
Return type:int or None
get_delay_minimum(synapse_info)[source]

Get the minimum delay specified by the user in ms, or None if unbounded.

Parameters:synapse_info (SynapseInformation) –
Return type:int or None
get_n_connections_from_pre_vertex_maximum(post_vertex_slice, synapse_info, min_delay=None, max_delay=None)[source]
Get the maximum number of connections between those from any
neuron in the pre vertex to the neurons in the post_vertex_slice, for connections with a delay between min_delay and max_delay (inclusive) if both specified (otherwise all connections).
Parameters:
Return type:

int

get_n_connections_to_post_vertex_maximum(synapse_info)[source]
Get the maximum number of connections between those to any neuron
in the post vertex from neurons in the pre vertex.
Parameters:synapse_info (SynapseInformation) –
Return type:int
get_weight_maximum(synapse_info)[source]

Get the maximum of the weights for this connection.

Parameters:synapse_info (SynapseInformation) –
Return type:float
class spynnaker.pyNN.models.neural_projections.connectors.CSAConnector(cset, safe=True, callback=None, verbose=False)[source]

Bases: spynnaker.pyNN.models.neural_projections.connectors.abstract_connector.AbstractConnector

Make connections using a Connection Set Algebra (Djurfeldt 2012) description between the neurons in the pre- and post-populations.

Note

If you get TypeError in Python 3 see: https://github.com/INCF/csa/issues/10

Parameters:
  • cset (csa.connset.CSet) – A description of the connection set between populations
  • safe (bool) – If True, check that weights and delays have valid values. If False, this check is skipped.
  • callback (callable) –

    if given, a callable that display a progress bar on the terminal.

    Note

    Not supported by sPyNNaker.

  • verbose (bool) – Whether to output extra information about the connectivity to a CSV file
Raises:

ImportError – if the csa library isn’t present; it’s tricky to install in some environments so we don’t force it to be present unless you want to actually use this class.

create_synaptic_block(pre_slices, post_slices, pre_vertex_slice, post_vertex_slice, synapse_type, synapse_info)[source]

Create a synaptic block from the data.

Parameters:
Returns:

The synaptic matrix data to go to the machine, as a Numpy array

Return type:

ndarray

get_delay_maximum(synapse_info)[source]

Get the maximum delay specified by the user in ms, or None if unbounded.

Parameters:synapse_info (SynapseInformation) – the synapse info
Return type:int or None
get_delay_minimum(synapse_info)[source]

Get the minimum delay specified by the user in ms, or None if unbounded.

Parameters:synapse_info (SynapseInformation) –
Return type:int or None
get_n_connections_from_pre_vertex_maximum(post_vertex_slice, synapse_info, min_delay=None, max_delay=None)[source]
Get the maximum number of connections between those from any
neuron in the pre vertex to the neurons in the post_vertex_slice, for connections with a delay between min_delay and max_delay (inclusive) if both specified (otherwise all connections).
Parameters:
Return type:

int

get_n_connections_to_post_vertex_maximum(synapse_info)[source]
Get the maximum number of connections between those to any neuron
in the post vertex from neurons in the pre vertex.
Parameters:synapse_info (SynapseInformation) –
Return type:int
get_weight_maximum(synapse_info)[source]

Get the maximum of the weights for this connection.

Parameters:synapse_info (SynapseInformation) –
Return type:float
show_connection_set(n_pre_neurons, n_post_neurons)[source]
Parameters:
  • n_pre_neurons (int) –
  • n_post_neurons (int) –
class spynnaker.pyNN.models.neural_projections.connectors.DistanceDependentProbabilityConnector(d_expression, allow_self_connections=True, safe=True, verbose=False, n_connections=None, rng=None, callback=None)[source]

Bases: spynnaker.pyNN.models.neural_projections.connectors.abstract_connector.AbstractConnector

Make connections using a distribution which varies with distance.

Parameters:
  • d_expression (str) – the right-hand side of a valid python expression for probability, involving d, (e.g. "exp(-abs(d))", or "d < 3"), that can be parsed by eval(), that computes the distance dependent distribution.
  • allow_self_connections (bool) – if the connector is used to connect a Population to itself, this flag determines whether a neuron is allowed to connect to itself, or only to other neurons in the Population.
  • safe (bool) – if True, check that weights and delays have valid values. If False, this check is skipped.
  • verbose (bool) – Whether to output extra information about the connectivity to a CSV file
  • n_connections (int or None) – The number of efferent synaptic connections per neuron.
  • rng (NumpyRNG or None) – Seeded random number generator, or None to make one when needed.
  • callback (callable) –
allow_self_connections
Return type:bool
create_synaptic_block(pre_slices, post_slices, pre_vertex_slice, post_vertex_slice, synapse_type, synapse_info)[source]

Create a synaptic block from the data.

Parameters:
Returns:

The synaptic matrix data to go to the machine, as a Numpy array

Return type:

ndarray

d_expression

The distance expression.

Return type:str
get_delay_maximum(synapse_info)[source]

Get the maximum delay specified by the user in ms, or None if unbounded.

Parameters:synapse_info (SynapseInformation) – the synapse info
Return type:int or None
get_delay_minimum(synapse_info)[source]

Get the minimum delay specified by the user in ms, or None if unbounded.

Parameters:synapse_info (SynapseInformation) –
Return type:int or None
get_n_connections_from_pre_vertex_maximum(post_vertex_slice, synapse_info, min_delay=None, max_delay=None)[source]
Get the maximum number of connections between those from any
neuron in the pre vertex to the neurons in the post_vertex_slice, for connections with a delay between min_delay and max_delay (inclusive) if both specified (otherwise all connections).
Parameters:
Return type:

int

get_n_connections_to_post_vertex_maximum(synapse_info)[source]
Get the maximum number of connections between those to any neuron
in the post vertex from neurons in the pre vertex.
Parameters:synapse_info (SynapseInformation) –
Return type:int
get_weight_maximum(synapse_info)[source]

Get the maximum of the weights for this connection.

Parameters:synapse_info (SynapseInformation) –
Return type:float
set_projection_information(synapse_info)[source]

sets a connectors projection info :param SynapseInformation synapse_info: the synapse info

class spynnaker.pyNN.models.neural_projections.connectors.FixedNumberPostConnector(n, allow_self_connections=True, safe=True, verbose=False, with_replacement=False, rng=None, callback=None)[source]

Bases: spynnaker.pyNN.models.neural_projections.connectors.abstract_generate_connector_on_machine.AbstractGenerateConnectorOnMachine, spynnaker.pyNN.models.neural_projections.connectors.abstract_connector_supports_views_on_machine.AbstractConnectorSupportsViewsOnMachine

Connects a fixed number of post-synaptic neurons selected at random, to all pre-synaptic neurons.

Parameters:
  • n (int) – number of random post-synaptic neurons connected to pre-neurons.
  • allow_self_connections (bool) – if the connector is used to connect a Population to itself, this flag determines whether a neuron is allowed to connect to itself, or only to other neurons in the Population.
  • safe (bool) – Whether to check that weights and delays have valid values; if False, this check is skipped.
  • verbose (bool) – Whether to output extra information about the connectivity to a CSV file
  • with_replacement (bool) – this flag determines how the random selection of post-synaptic neurons is performed; if True, then every post-synaptic neuron can be chosen on each occasion, and so multiple connections between neuron pairs are possible; if False, then once a post-synaptic neuron has been connected to a pre-neuron, it can’t be connected again.
  • rng (NumpyRNG or None) – Seeded random number generator, or None to make one when needed.
  • callback (callable) –

    if given, a callable that display a progress bar on the terminal.

    Note

    Not supported by sPyNNaker.

allow_self_connections
create_synaptic_block(pre_slices, post_slices, pre_vertex_slice, post_vertex_slice, synapse_type, synapse_info)[source]

Create a synaptic block from the data.

Parameters:
Returns:

The synaptic matrix data to go to the machine, as a Numpy array

Return type:

ndarray

gen_connector_id

The ID of the connection generator on the machine.

Return type:int
gen_connector_params(pre_slices, post_slices, pre_vertex_slice, post_vertex_slice, synapse_type, synapse_info)[source]

Get the parameters of the on machine generation.

Parameters:
Return type:

ndarray(uint32)

gen_connector_params_size_in_bytes

The size of the connector parameters in bytes.

Return type:int
get_delay_maximum(synapse_info)[source]

Get the maximum delay specified by the user in ms, or None if unbounded.

Parameters:synapse_info (SynapseInformation) – the synapse info
Return type:int or None
get_delay_minimum(synapse_info)[source]

Get the minimum delay specified by the user in ms, or None if unbounded.

Parameters:synapse_info (SynapseInformation) –
Return type:int or None
get_n_connections_from_pre_vertex_maximum(post_vertex_slice, synapse_info, min_delay=None, max_delay=None)[source]
Get the maximum number of connections between those from any
neuron in the pre vertex to the neurons in the post_vertex_slice, for connections with a delay between min_delay and max_delay (inclusive) if both specified (otherwise all connections).
Parameters:
Return type:

int

get_n_connections_to_post_vertex_maximum(synapse_info)[source]
Get the maximum number of connections between those to any neuron
in the post vertex from neurons in the pre vertex.
Parameters:synapse_info (SynapseInformation) –
Return type:int
get_weight_maximum(synapse_info)[source]

Get the maximum of the weights for this connection.

Parameters:synapse_info (SynapseInformation) –
Return type:float
set_projection_information(synapse_info)[source]

sets a connectors projection info :param SynapseInformation synapse_info: the synapse info

class spynnaker.pyNN.models.neural_projections.connectors.FixedNumberPreConnector(n, allow_self_connections=True, safe=True, verbose=False, with_replacement=False, rng=None, callback=None)[source]

Bases: spynnaker.pyNN.models.neural_projections.connectors.abstract_generate_connector_on_machine.AbstractGenerateConnectorOnMachine, spynnaker.pyNN.models.neural_projections.connectors.abstract_connector_supports_views_on_machine.AbstractConnectorSupportsViewsOnMachine

Connects a fixed number of pre-synaptic neurons selected at random, to all post-synaptic neurons.

Parameters:
  • n (int) – number of random pre-synaptic neurons connected to output
  • allow_self_connections (bool) – if the connector is used to connect a Population to itself, this flag determines whether a neuron is allowed to connect to itself, or only to other neurons in the Population.
  • safe (bool) – Whether to check that weights and delays have valid values. If False, this check is skipped.
  • verbose (bool) – Whether to output extra information about the connectivity to a CSV file
  • with_replacement (bool) – this flag determines how the random selection of pre-synaptic neurons is performed; if true, then every pre-synaptic neuron can be chosen on each occasion, and so multiple connections between neuron pairs are possible; if false, then once a pre-synaptic neuron has been connected to a post-neuron, it can’t be connected again.
  • rng (NumpyRNG or None) – Seeded random number generator, or None to make one when needed
  • callback (callable) –

    if given, a callable that display a progress bar on the terminal.

    Note

    Not supported by sPyNNaker.

allow_self_connections
create_synaptic_block(pre_slices, post_slices, pre_vertex_slice, post_vertex_slice, synapse_type, synapse_info)[source]

Create a synaptic block from the data.

Parameters:
Returns:

The synaptic matrix data to go to the machine, as a Numpy array

Return type:

ndarray

gen_connector_id

The ID of the connection generator on the machine.

Return type:int
gen_connector_params(pre_slices, post_slices, pre_vertex_slice, post_vertex_slice, synapse_type, synapse_info)[source]

Get the parameters of the on machine generation.

Parameters:
Return type:

ndarray(uint32)

gen_connector_params_size_in_bytes

The size of the connector parameters in bytes.

Return type:int
get_delay_maximum(synapse_info)[source]

Get the maximum delay specified by the user in ms, or None if unbounded.

Parameters:synapse_info (SynapseInformation) – the synapse info
Return type:int or None
get_delay_minimum(synapse_info)[source]

Get the minimum delay specified by the user in ms, or None if unbounded.

Parameters:synapse_info (SynapseInformation) –
Return type:int or None
get_n_connections_from_pre_vertex_maximum(post_vertex_slice, synapse_info, min_delay=None, max_delay=None)[source]
Get the maximum number of connections between those from any
neuron in the pre vertex to the neurons in the post_vertex_slice, for connections with a delay between min_delay and max_delay (inclusive) if both specified (otherwise all connections).
Parameters:
Return type:

int

get_n_connections_to_post_vertex_maximum(synapse_info)[source]
Get the maximum number of connections between those to any neuron
in the post vertex from neurons in the pre vertex.
Parameters:synapse_info (SynapseInformation) –
Return type:int
get_weight_maximum(synapse_info)[source]

Get the maximum of the weights for this connection.

Parameters:synapse_info (SynapseInformation) –
Return type:float
set_projection_information(synapse_info)[source]

sets a connectors projection info :param SynapseInformation synapse_info: the synapse info

class spynnaker.pyNN.models.neural_projections.connectors.FixedProbabilityConnector(p_connect, allow_self_connections=True, safe=True, verbose=False, rng=None, callback=None)[source]

Bases: spynnaker.pyNN.models.neural_projections.connectors.abstract_generate_connector_on_machine.AbstractGenerateConnectorOnMachine, spynnaker.pyNN.models.neural_projections.connectors.abstract_connector_supports_views_on_machine.AbstractConnectorSupportsViewsOnMachine

For each pair of pre-post cells, the connection probability is constant.

Parameters:
  • p_connect (float) – a value between zero and one. Each potential connection is created with this probability.
  • allow_self_connections (bool) – if the connector is used to connect a Population to itself, this flag determines whether a neuron is allowed to connect to itself, or only to other neurons in the Population.
  • safe (bool) – If True, check that weights and delays have valid values. If False, this check is skipped.
  • verbose (bool) – Whether to output extra information about the connectivity to a CSV file
  • rng (NumpyRNG or None) – Seeded random number generator, or None to make one when needed
  • callback (callable) –

    if given, a callable that display a progress bar on the terminal.

    Note

    Not supported by sPyNNaker.

create_synaptic_block(pre_slices, post_slices, pre_vertex_slice, post_vertex_slice, synapse_type, synapse_info)[source]

Create a synaptic block from the data.

Parameters:
Returns:

The synaptic matrix data to go to the machine, as a Numpy array

Return type:

ndarray

gen_connector_id

The ID of the connection generator on the machine.

Return type:int
gen_connector_params(pre_slices, post_slices, pre_vertex_slice, post_vertex_slice, synapse_type, synapse_info)[source]

Get the parameters of the on machine generation.

Parameters:
Return type:

ndarray(uint32)

gen_connector_params_size_in_bytes

The size of the connector parameters in bytes.

Return type:int
get_delay_maximum(synapse_info)[source]

Get the maximum delay specified by the user in ms, or None if unbounded.

Parameters:synapse_info (SynapseInformation) – the synapse info
Return type:int or None
get_delay_minimum(synapse_info)[source]

Get the minimum delay specified by the user in ms, or None if unbounded.

Parameters:synapse_info (SynapseInformation) –
Return type:int or None
get_n_connections_from_pre_vertex_maximum(post_vertex_slice, synapse_info, min_delay=None, max_delay=None)[source]
Get the maximum number of connections between those from any
neuron in the pre vertex to the neurons in the post_vertex_slice, for connections with a delay between min_delay and max_delay (inclusive) if both specified (otherwise all connections).
Parameters:
Return type:

int

get_n_connections_to_post_vertex_maximum(synapse_info)[source]
Get the maximum number of connections between those to any neuron
in the post vertex from neurons in the pre vertex.
Parameters:synapse_info (SynapseInformation) –
Return type:int
get_weight_maximum(synapse_info)[source]

Get the maximum of the weights for this connection.

Parameters:synapse_info (SynapseInformation) –
Return type:float
p_connect
class spynnaker.pyNN.models.neural_projections.connectors.FromFileConnector(file, distributed=False, safe=True, callback=None, verbose=False)[source]

Bases: spynnaker.pyNN.models.neural_projections.connectors.from_list_connector.FromListConnector

Make connections according to a list read from a file.

Parameters:
  • file (str or FileIO) –

    Either an open file object or the filename of a file containing a list of connections, in the format required by FromListConnector. Column headers, if included in the file, must be specified using a list or tuple, e.g.:

    # columns = ["i", "j", "weight", "delay", "U", "tau_rec"]
    

    Note that the header requires # at the beginning of the line.

  • distributed (bool) –

    Basic pyNN says:

    if this is True, then each node will read connections from a file called filename.x, where x is the MPI rank. This speeds up loading connections for distributed simulations.

    Note

    Always leave this as False with sPyNNaker, which is not MPI-based.

  • safe (bool) – Whether to check that weights and delays have valid values. If False, this check is skipped.
  • callback (callable) –

    if given, a callable that display a progress bar on the terminal.

    Note

    Not supported by sPyNNaker.

  • verbose (bool) – Whether to output extra information about the connectivity to a CSV file
get_reader(file)[source]

Get a file reader object using the PyNN methods.

Returns:A pynn StandardTextFile or similar
Return type:StandardTextFile
class spynnaker.pyNN.models.neural_projections.connectors.FromListConnector(conn_list, safe=True, verbose=False, column_names=None, callback=None)[source]

Bases: spynnaker.pyNN.models.neural_projections.connectors.abstract_connector.AbstractConnector

Make connections according to a list.

Parameters:
  • conn_list (ndarray or list(tuple(int,int,..))) –

    A numpy array or a list of tuples, one tuple for each connection. Each tuple should contain:

    (pre_idx, post_idx, p1, p2, ..., pn)
    

    where pre_idx is the index (i.e. order in the Population, not the ID) of the presynaptic neuron, post_idx is the index of the postsynaptic neuron, and p1, p2, etc. are the synaptic parameters (e.g., weight, delay, plasticity parameters). All tuples/rows must have the same number of items.

  • safe (bool) – if True, check that weights and delays have valid values. If False, this check is skipped.
  • verbose (bool) – Whether to output extra information about the connectivity to a CSV file
  • column_names (None or tuple(str) or list(str)) – the names of the parameters p1, p2, etc. If not provided, it is assumed the parameters are weight, delay (for backwards compatibility).
  • callback (callable) –

    if given, a callable that display a progress bar on the terminal.

    Note

    Not supported by sPyNNaker.

column_names

The names of the columns in the array after the first two. Of particular interest is whether weight and delay columns are present.

Return type:list(str)
conn_list

The connection list.

Return type:ndarray
could_connect(_synapse_info, _pre_slice, _post_slice)[source]

Checks if a pre slice and a post slice could connect.

Typically used to determine if a Machine Edge should be created by checking that at least one of the indexes in the pre slice could over time connect to at least one of the indexes in the post slice.

Note

This method should never return a false negative, but may return a false positives

Parameters:
Return type:

bool

create_synaptic_block(pre_slices, post_slices, pre_vertex_slice, post_vertex_slice, synapse_type, synapse_info)[source]

Create a synaptic block from the data.

Parameters:
Returns:

The synaptic matrix data to go to the machine, as a Numpy array

Return type:

ndarray

get_delay_maximum(synapse_info)[source]

Get the maximum delay specified by the user in ms, or None if unbounded.

Parameters:synapse_info (SynapseInformation) – the synapse info
Return type:int or None
get_delay_minimum(synapse_info)[source]

Get the minimum delay specified by the user in ms, or None if unbounded.

Parameters:synapse_info (SynapseInformation) –
Return type:int or None
get_delay_variance(delays, synapse_info)[source]

Get the variance of the delays.

Parameters:delays (ndarray or NumpyRNG or int or float or list(int) or list(float)) –
Return type:float
get_extra_parameter_names()[source]

Getter for the names of the extra parameters.

Return type:list(str)
get_extra_parameters()[source]

Getter for the extra parameters. Excludes weight and delay columns.

Returns:The extra parameters
Return type:ndarray
get_n_connections(pre_slices, post_slices, pre_hi, post_hi)[source]
Parameters:
Return type:

int

get_n_connections_from_pre_vertex_maximum(post_vertex_slice, synapse_info, min_delay=None, max_delay=None)[source]
Get the maximum number of connections between those from any
neuron in the pre vertex to the neurons in the post_vertex_slice, for connections with a delay between min_delay and max_delay (inclusive) if both specified (otherwise all connections).
Parameters:
Return type:

int

get_n_connections_to_post_vertex_maximum(synapse_info)[source]
Get the maximum number of connections between those to any neuron
in the post vertex from neurons in the pre vertex.
Parameters:synapse_info (SynapseInformation) –
Return type:int
get_weight_maximum(synapse_info)[source]

Get the maximum of the weights for this connection.

Parameters:synapse_info (SynapseInformation) –
Return type:float
get_weight_mean(weights, synapse_info)[source]

Get the mean of the weights.

Parameters:weights (ndarray or NumpyRNG or int or float or list(int) or list(float)) –
Return type:float
get_weight_variance(weights, synapse_info)[source]

Get the variance of the weights.

Parameters:weights (ndarray or NumpyRNG or int or float or list(int) or list(float)) –
Return type:float
class spynnaker.pyNN.models.neural_projections.connectors.IndexBasedProbabilityConnector(index_expression, allow_self_connections=True, rng=None, safe=True, callback=None, verbose=False)[source]

Bases: spynnaker.pyNN.models.neural_projections.connectors.abstract_connector.AbstractConnector

Make connections using a probability distribution which varies dependent upon the indices of the pre- and post-populations.

Parameters:
  • index_expression (str) – the right-hand side of a valid python expression for probability, involving the indices of the pre and post populations, that can be parsed by eval(), that computes a probability dist; the indices will be given as variables i and j when the expression is evaluated.
  • allow_self_connections (bool) – if the connector is used to connect a Population to itself, this flag determines whether a neuron is allowed to connect to itself, or only to other neurons in the Population.
  • rng (NumpyRNG or None) – Seeded random number generator, or None to make one when needed.
  • safe (bool) – Whether to check that weights and delays have valid values. If False, this check is skipped.
  • callback (callable) –

    if given, a callable that display a progress bar on the terminal.

    Note

    Not supported by sPyNNaker.

  • verbose (bool) – Whether to output extra information about the connectivity to a CSV file
allow_self_connections

If the connector is used to connect a Population to itself, this flag determines whether a neuron is allowed to connect to itself, or only to other neurons in the Population.

Return type:bool
create_synaptic_block(pre_slices, post_slices, pre_vertex_slice, post_vertex_slice, synapse_type, synapse_info)[source]

Create a synaptic block from the data.

Parameters:
Returns:

The synaptic matrix data to go to the machine, as a Numpy array

Return type:

ndarray

get_delay_maximum(synapse_info)[source]

Get the maximum delay specified by the user in ms, or None if unbounded.

Parameters:synapse_info (SynapseInformation) – the synapse info
Return type:int or None
get_delay_minimum(synapse_info)[source]

Get the minimum delay specified by the user in ms, or None if unbounded.

Parameters:synapse_info (SynapseInformation) –
Return type:int or None
get_n_connections_from_pre_vertex_maximum(post_vertex_slice, synapse_info, min_delay=None, max_delay=None)[source]
Get the maximum number of connections between those from any
neuron in the pre vertex to the neurons in the post_vertex_slice, for connections with a delay between min_delay and max_delay (inclusive) if both specified (otherwise all connections).
Parameters:
Return type:

int

get_n_connections_to_post_vertex_maximum(synapse_info)[source]
Get the maximum number of connections between those to any neuron
in the post vertex from neurons in the pre vertex.
Parameters:synapse_info (SynapseInformation) –
Return type:int
get_weight_maximum(synapse_info)[source]

Get the maximum of the weights for this connection.

Parameters:synapse_info (SynapseInformation) –
Return type:float
index_expression

The right-hand side of a valid python expression for probability, involving the indices of the pre and post populations, that can be parsed by eval(), that computes a probability dist.

Return type:str
class spynnaker.pyNN.models.neural_projections.connectors.KernelConnector(shape_pre, shape_post, shape_kernel, weight_kernel=None, delay_kernel=None, shape_common=None, pre_sample_steps_in_post=None, pre_start_coords_in_post=None, post_sample_steps_in_pre=None, post_start_coords_in_pre=None, safe=True, space=None, verbose=False, callback=None)[source]

Bases: spynnaker.pyNN.models.neural_projections.connectors.abstract_generate_connector_on_machine.AbstractGenerateConnectorOnMachine

Where the pre- and post-synaptic populations are considered as a 2D array. Connect every post(row, col) neuron to many pre(row, col, kernel) through a (kernel) set of weights and/or delays.

TODO

Should these include allow_self_connections and with_replacement?

Parameters:
  • shape_pre (list(int) or tuple(int,int)) – 2D shape of the pre population (rows/height, cols/width, usually the input image shape)
  • shape_post (list(int) or tuple(int,int)) – 2D shape of the post population (rows/height, cols/width)
  • shape_kernel (list(int) or tuple(int,int)) – 2D shape of the kernel (rows/height, cols/width)
  • weight_kernel (ndarray or NumpyRNG or int or float or list(int) or list(float) or None) – (optional) 2D matrix of size shape_kernel describing the weights
  • delay_kernel (ndarray or NumpyRNG or int or float or list(int) or list(float) or None) – (optional) 2D matrix of size shape_kernel describing the delays
  • shape_common (list(int) or tuple(int,int) or None) – (optional) 2D shape of common coordinate system (for both pre and post, usually the input image sizes)
  • pre_sample_steps_in_post (None or list(int) or tuple(int,int)) – (optional) Sampling steps/jumps for pre pop <=> (stepX, stepY)
  • pre_start_coords_in_post (None or list(int) or tuple(int,int)) – (optional) Starting row/col for pre sampling <=> (offX, offY)
  • post_sample_steps_in_pre (None or list(int) or tuple(int,int)) – (optional) Sampling steps/jumps for post pop <=> (stepX, stepY)
  • post_start_coords_in_pre (None or list(int) or tuple(int,int)) – (optional) Starting row/col for post sampling <=> (offX, offY)
  • safe (bool) – Whether to check that weights and delays have valid values. If False, this check is skipped.
  • space (Space) – Currently ignored; for future compatibility.
  • verbose (bool) – Whether to output extra information about the connectivity to a CSV file
  • callback (callable) – (ignored)
create_synaptic_block(pre_slices, post_slices, pre_vertex_slice, post_vertex_slice, synapse_type, synapse_info)[source]

Create a synaptic block from the data.

Parameters:
Returns:

The synaptic matrix data to go to the machine, as a Numpy array

Return type:

ndarray

gen_connector_id

The ID of the connection generator on the machine.

Return type:int
gen_connector_params(pre_slices, post_slices, pre_vertex_slice, post_vertex_slice, synapse_type, synapse_info)[source]

Get the parameters of the on machine generation.

Parameters:
Return type:

ndarray(uint32)

gen_connector_params_size_in_bytes

The size of the connector parameters in bytes.

Return type:int
gen_delay_params(delays, pre_vertex_slice, post_vertex_slice)[source]

Get the parameters of the delay generator on the machine

Parameters:
Return type:

ndarray(uint32)

gen_delay_params_size_in_bytes(delays)[source]

The size of the delay parameters in bytes

Parameters:delays (ndarray or NumpyRNG or int or float or list(int) or list(float)) –
Return type:int
gen_delays_id(delays)[source]

Get the id of the delay generator on the machine

Parameters:delays (ndarray or NumpyRNG or int or float or list(int) or list(float)) –
Return type:int
gen_weight_params_size_in_bytes(weights)[source]

The size of the weight parameters in bytes

Parameters:weights (ndarray or NumpyRNG or int or float or list(int) or list(float)) –
Return type:int
gen_weights_id(weights)[source]

Get the id of the weight generator on the machine

Parameters:weights (ndarray or NumpyRNG or int or float or list(int) or list(float)) –
Return type:int
gen_weights_params(weights, pre_vertex_slice, post_vertex_slice)[source]

Get the parameters of the weight generator on the machine

Parameters:
Return type:

ndarray(uint32)

get_delay_maximum(synapse_info)[source]

Get the maximum delay specified by the user in ms, or None if unbounded.

Parameters:synapse_info (SynapseInformation) – the synapse info
Return type:int or None
get_delay_minimum(synapse_info)[source]

Get the minimum delay specified by the user in ms, or None if unbounded.

Parameters:synapse_info (SynapseInformation) –
Return type:int or None
get_n_connections_from_pre_vertex_maximum(post_vertex_slice, synapse_info, min_delay=None, max_delay=None)[source]
Get the maximum number of connections between those from any
neuron in the pre vertex to the neurons in the post_vertex_slice, for connections with a delay between min_delay and max_delay (inclusive) if both specified (otherwise all connections).
Parameters:
Return type:

int

get_n_connections_to_post_vertex_maximum(synapse_info)[source]
Get the maximum number of connections between those to any neuron
in the post vertex from neurons in the pre vertex.
Parameters:synapse_info (SynapseInformation) –
Return type:int
get_weight_maximum(synapse_info)[source]

Get the maximum of the weights for this connection.

Parameters:synapse_info (SynapseInformation) –
Return type:float
class spynnaker.pyNN.models.neural_projections.connectors.MultapseConnector(n, allow_self_connections=True, with_replacement=True, safe=True, verbose=False, rng=None, callback=None)[source]

Bases: spynnaker.pyNN.models.neural_projections.connectors.abstract_generate_connector_on_machine.AbstractGenerateConnectorOnMachine, spynnaker.pyNN.models.neural_projections.connectors.abstract_connector_supports_views_on_machine.AbstractConnectorSupportsViewsOnMachine

Create a multapse connector. The size of the source and destination populations are obtained when the projection is connected. The number of synapses is specified. when instantiated, the required number of synapses is created by selecting at random from the source and target populations with replacement. Uniform selection probability is assumed.

Parameters:
  • n (int) – This is the total number of synapses in the connection.
  • allow_self_connections (bool) – Allow a neuron to connect to itself or not.
  • with_replacement (bool) – When selecting, allow a neuron to be re-selected or not.
  • safe (bool) – Whether to check that weights and delays have valid values. If False, this check is skipped.
  • verbose (bool) – Whether to output extra information about the connectivity to a CSV file
  • rng (NumpyRNG or None) – Seeded random number generator, or None to make one when needed.
  • callback (callable) –

    if given, a callable that display a progress bar on the terminal.

    Note

    Not supported by sPyNNaker.

create_synaptic_block(pre_slices, post_slices, pre_vertex_slice, post_vertex_slice, synapse_type, synapse_info)[source]

Create a synaptic block from the data.

Parameters:
Returns:

The synaptic matrix data to go to the machine, as a Numpy array

Return type:

ndarray

gen_connector_id

The ID of the connection generator on the machine.

Return type:int
gen_connector_params(pre_slices, post_slices, pre_vertex_slice, post_vertex_slice, synapse_type, synapse_info)[source]

Get the parameters of the on machine generation.

Parameters:
Return type:

ndarray(uint32)

gen_connector_params_size_in_bytes

The size of the connector parameters in bytes.

Return type:int
get_delay_maximum(synapse_info)[source]

Get the maximum delay specified by the user in ms, or None if unbounded.

Parameters:synapse_info (SynapseInformation) – the synapse info
Return type:int or None
get_delay_minimum(synapse_info)[source]

Get the minimum delay specified by the user in ms, or None if unbounded.

Parameters:synapse_info (SynapseInformation) –
Return type:int or None
get_n_connections_from_pre_vertex_maximum(post_vertex_slice, synapse_info, min_delay=None, max_delay=None)[source]
Get the maximum number of connections between those from any
neuron in the pre vertex to the neurons in the post_vertex_slice, for connections with a delay between min_delay and max_delay (inclusive) if both specified (otherwise all connections).
Parameters:
Return type:

int

get_n_connections_to_post_vertex_maximum(synapse_info)[source]
Get the maximum number of connections between those to any neuron
in the post vertex from neurons in the pre vertex.
Parameters:synapse_info (SynapseInformation) –
Return type:int
get_rng_next(num_synapses, prob_connect)[source]

Get the required RNGs

Parameters:
  • num_synapses (int) – The number of synapses to make random numbers for in this call
  • prob_connect (list(float)) – The probability of connection
Return type:

ndarray

get_weight_maximum(synapse_info)[source]

Get the maximum of the weights for this connection.

Parameters:synapse_info (SynapseInformation) –
Return type:float
class spynnaker.pyNN.models.neural_projections.connectors.OneToOneConnector(safe=True, callback=None, verbose=False)[source]

Bases: spynnaker.pyNN.models.neural_projections.connectors.abstract_generate_connector_on_machine.AbstractGenerateConnectorOnMachine, spynnaker.pyNN.models.neural_projections.connectors.abstract_connector_supports_views_on_machine.AbstractConnectorSupportsViewsOnMachine

Where the pre- and postsynaptic populations have the same size, connect cell i in the presynaptic population to cell i in the postsynaptic population, for all i.

Parameters:
  • safe (bool) – If True, check that weights and delays have valid values. If False, this check is skipped.
  • callback (callable) –

    if given, a callable that display a progress bar on the terminal.

    Note

    Not supported by sPyNNaker.

  • verbose (bool) – Whether to output extra information about the connectivity to a CSV file
could_connect(_synapse_info, _pre_slice, _post_slice)[source]

Checks if a pre slice and a post slice could connect.

Typically used to determine if a Machine Edge should be created by checking that at least one of the indexes in the pre slice could over time connect to at least one of the indexes in the post slice.

Note

This method should never return a false negative, but may return a false positives

Parameters:
Return type:

bool

create_synaptic_block(pre_slices, post_slices, pre_vertex_slice, post_vertex_slice, synapse_type, synapse_info)[source]

Create a synaptic block from the data.

Parameters:
Returns:

The synaptic matrix data to go to the machine, as a Numpy array

Return type:

ndarray

gen_connector_id

The ID of the connection generator on the machine.

Return type:int
gen_connector_params(pre_slices, post_slices, pre_vertex_slice, post_vertex_slice, synapse_type, synapse_info)[source]

Get the parameters of the on machine generation.

Parameters:
Return type:

ndarray(uint32)

gen_connector_params_size_in_bytes

The size of the connector parameters in bytes.

Return type:int
get_delay_maximum(synapse_info)[source]

Get the maximum delay specified by the user in ms, or None if unbounded.

Parameters:synapse_info (SynapseInformation) – the synapse info
Return type:int or None
get_delay_minimum(synapse_info)[source]

Get the minimum delay specified by the user in ms, or None if unbounded.

Parameters:synapse_info (SynapseInformation) –
Return type:int or None
get_n_connections_from_pre_vertex_maximum(post_vertex_slice, synapse_info, min_delay=None, max_delay=None)[source]
Get the maximum number of connections between those from any
neuron in the pre vertex to the neurons in the post_vertex_slice, for connections with a delay between min_delay and max_delay (inclusive) if both specified (otherwise all connections).
Parameters:
Return type:

int

get_n_connections_to_post_vertex_maximum(synapse_info)[source]
Get the maximum number of connections between those to any neuron
in the post vertex from neurons in the pre vertex.
Parameters:synapse_info (SynapseInformation) –
Return type:int
get_weight_maximum(synapse_info)[source]

Get the maximum of the weights for this connection.

Parameters:synapse_info (SynapseInformation) –
Return type:float
use_direct_matrix(synapse_info)[source]
Parameters:synapse_info (SynapseInformation) –
Return type:bool
class spynnaker.pyNN.models.neural_projections.connectors.SmallWorldConnector(degree, rewiring, allow_self_connections=True, n_connections=None, rng=None, safe=True, callback=None, verbose=False)[source]

Bases: spynnaker.pyNN.models.neural_projections.connectors.abstract_connector.AbstractConnector

A connector that uses connection statistics based on the Small World network connectivity model.

Note

This is typically used from a population to itself.

Parameters:
  • degree (float) – the region length where nodes will be connected locally
  • rewiring (float) – the probability of rewiring each edge
  • allow_self_connections (bool) – if the connector is used to connect a Population to itself, this flag determines whether a neuron is allowed to connect to itself, or only to other neurons in the Population.
  • n_connections (int or None) – if specified, the number of efferent synaptic connections per neuron
  • rng (NumpyRNG or None) – Seeded random number generator, or None to make one when needed.
  • safe (bool) – If True, check that weights and delays have valid values. If False, this check is skipped.
  • callback (callable) –

    if given, a callable that display a progress bar on the terminal.

    Note

    Not supported by sPyNNaker.

  • verbose (bool) – Whether to output extra information about the connectivity to a CSV file
create_synaptic_block(pre_slices, post_slices, pre_vertex_slice, post_vertex_slice, synapse_type, synapse_info)[source]

Create a synaptic block from the data.

Parameters:
Returns:

The synaptic matrix data to go to the machine, as a Numpy array

Return type:

ndarray

get_delay_maximum(synapse_info)[source]

Get the maximum delay specified by the user in ms, or None if unbounded.

Parameters:synapse_info (SynapseInformation) – the synapse info
Return type:int or None
get_delay_minimum(synapse_info)[source]

Get the minimum delay specified by the user in ms, or None if unbounded.

Parameters:synapse_info (SynapseInformation) –
Return type:int or None
get_n_connections_from_pre_vertex_maximum(post_vertex_slice, synapse_info, min_delay=None, max_delay=None)[source]
Get the maximum number of connections between those from any
neuron in the pre vertex to the neurons in the post_vertex_slice, for connections with a delay between min_delay and max_delay (inclusive) if both specified (otherwise all connections).
Parameters:
Return type:

int

get_n_connections_to_post_vertex_maximum(synapse_info)[source]
Get the maximum number of connections between those to any neuron
in the post vertex from neurons in the pre vertex.
Parameters:synapse_info (SynapseInformation) –
Return type:int
get_weight_maximum(synapse_info)[source]

Get the maximum of the weights for this connection.

Parameters:synapse_info (SynapseInformation) –
Return type:float
set_projection_information(synapse_info)[source]

sets a connectors projection info :param SynapseInformation synapse_info: the synapse info