sPyNNaker

The spynnaker.pyNN package contains the front end specifications and implementation for the PyNN High-level API (http://neuralensemble.org/trac/PyNN).

This package contains the profile of that code for PyNN 0.9

class spynnaker8.Cuboid(width, height, depth)[source]

Represents a cuboidal volume within which neurons may be distributed.

Arguments:
height:
extent in y direction
width:
extent in x direction
depth:
extent in z direction
sample(n, rng)[source]

Return n points distributed randomly with uniform density within the cuboid.

spynnaker8.distance(src, tgt, mask=None, scale_factor=1.0, offset=0.0, periodic_boundaries=None)[source]

Return the Euclidian distance between two cells.

Parameters:
  • src
  • tgt
  • mask (ndarray) – allows only certain dimensions to be considered, e.g.: * to ignore the z-dimension, use mask=array([0,1]) * to ignore y, mask=array([0,2]) * to just consider z-distance, mask=array([2])
  • scale_factor (float) – allows for different units in the pre- and post-position (the post-synaptic position is multiplied by this quantity).
  • offset (float) –
  • periodic_boundaries
class spynnaker8.Grid2D(aspect_ratio=1.0, dx=1.0, dy=1.0, x0=0.0, y0=0.0, z=0, fill_order='sequential', rng=None)[source]

Represents a structure with neurons distributed on a 2D grid.

Arguments:
dx, dy:
distances between points in the x, y directions.
x0, y0:
coordinates of the starting corner of the grid.
z:
the z-coordinate of all points in the grid.
aspect_ratio:
ratio of the number of grid points per side (not the ratio of the side lengths, unless dx == dy)
fill_order:
may be ‘sequential’ or ‘random’
calculate_size(n)[source]

docstring goes here

generate_positions(n)[source]

Calculate and return the positions of n neurons positioned according to this structure.

class spynnaker8.Grid3D(aspect_ratioXY=1.0, aspect_ratioXZ=1.0, dx=1.0, dy=1.0, dz=1.0, x0=0.0, y0=0.0, z0=0, fill_order='sequential', rng=None)[source]

Represents a structure with neurons distributed on a 3D grid.

Arguments:
dx, dy, dz:
distances between points in the x, y, z directions.
x0, y0. z0:
coordinates of the starting corner of the grid.
aspect_ratioXY, aspect_ratioXZ:
ratios of the number of grid points per side (not the ratio of the side lengths, unless dx == dy == dz)
fill_order:
may be ‘sequential’ or ‘random’.

If fill_order is ‘sequential’, the z-index will be filled first, then y then x, i.e. the first cell will be at (0,0,0) (given default values for the other arguments), the second at (0,0,1), etc.

calculate_size(n)[source]

docstring goes here

generate_positions(n)[source]

Calculate and return the positions of n neurons positioned according to this structure.

class spynnaker8.Line(dx=1.0, x0=0.0, y=0.0, z=0.0)[source]

Represents a structure with neurons distributed evenly on a straight line.

Arguments:
dx:
distance between points in the line.
y, z,:
y- and z-coordinates of all points in the line.
x0:
x-coordinate of the first point in the line.
generate_positions(n)[source]

Calculate and return the positions of n neurons positioned according to this structure.

class spynnaker8.NumpyRNG(seed=None, parallel_safe=True)[source]

Wrapper for the numpy.random.RandomState class (Mersenne Twister PRNG).

normal_clipped(mu=0.0, sigma=1.0, low=-inf, high=inf, size=None)[source]
class spynnaker8.RandomDistribution(distribution, parameters_pos=None, rng=None, **parameters_named)[source]

Class which defines a next(n) method which returns an array of n random numbers from a given distribution.

Parameters:
  • distribution (str) – the name of a random number distribution.
  • parameters_pos (tuple or None) – parameters of the distribution, provided as a tuple. For the correct ordering, see random.available_distributions.
  • rng (NumpyRNG or GSLRNG or NativeRNG or None) – the random number generator to use, if a specific one is desired (e.g., to provide a seed).
  • parameters_named – parameters of the distribution, provided as keyword arguments.

Parameters may be provided either through parameters_pos or through parameters_named, but not both. All parameters must be provided, there are no default values. Parameter names are, in general, as used in Wikipedia.

Examples:

>>> rd = RandomDistribution('uniform', (-70, -50))
>>> rd = RandomDistribution('normal', mu=0.5, sigma=0.1)
>>> rng = NumpyRNG(seed=8658764)
>>> rd = RandomDistribution('gamma', k=2.0, theta=5.0, rng=rng)
Available distributions
Name Parameters Comments
binomial n, p  
gamma k, theta  
exponential beta  
lognormal mu, sigma  
normal mu, sigma  
normal_clipped mu, sigma, low, high Values outside (low, high) are redrawn
normal_clipped_to_boundary mu, sigma, low, high Values below/above low/high are set to low/high
poisson lambda_ Trailing underscore since lambda is a Python keyword
uniform low, high  
uniform_int low, high Only generates integer values
vonmises mu, kappa  

Create a new RandomDistribution.

class spynnaker8.RandomStructure(boundary, origin=(0.0, 0.0, 0.0), rng=None)[source]

Represents a structure with neurons distributed randomly within a given volume.

Arguments:
boundary - a subclass of Shape. origin - the coordinates (x,y,z) of the centre of the volume.
generate_positions(n)[source]

Calculate and return the positions of n neurons positioned according to this structure.

class spynnaker8.Space(axes=None, scale_factor=1.0, offset=0.0, periodic_boundaries=None)[source]

Class representing a space within distances can be calculated. The space is Cartesian, may be 1-, 2- or 3-dimensional, and may have periodic boundaries in any of the dimensions.

Arguments:
axes:
if not supplied, then the 3D distance is calculated. If supplied, axes should be a string containing the axes to be used, e.g. ‘x’, or ‘yz’. axes=’xyz’ is the same as axes=None.
scale_factor:
it may be that the pre and post populations use different units for position, e.g. degrees and µm. In this case, scale_factor can be specified, which is applied to the positions in the post-synaptic population.
offset:
if the origins of the coordinate systems of the pre- and post- synaptic populations are different, offset can be used to adjust for this difference. The offset is applied before any scaling.
periodic_boundaries:
either None, or a tuple giving the boundaries for each dimension, e.g. ((x_min, x_max), None, (z_min, z_max)).
distances(A, B, expand=False)[source]

Calculate the distance matrix between two sets of coordinates, given the topology of the current space. From http://projects.scipy.org/pipermail/numpy-discussion/2007-April/027203.html

class spynnaker8.Sphere(radius)[source]

Represents a spherical volume within which neurons may be distributed.

sample(n, rng)[source]

Return n points distributed randomly with uniform density within the sphere.

class spynnaker8.AllToAllConnector(allow_self_connections=True, safe=True, verbose=None, callback=None)[source]

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 spynnaker8.ArrayConnector(array, safe=True, callback=None, verbose=False)[source]

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 spynnaker8.CSAConnector(cset, safe=True, callback=None, verbose=False)[source]

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 spynnaker8.DistanceDependentProbabilityConnector(d_expression, allow_self_connections=True, safe=True, verbose=False, n_connections=None, rng=None, callback=None)[source]

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 spynnaker8.FixedNumberPostConnector(n, allow_self_connections=True, safe=True, verbose=False, with_replacement=False, rng=None, callback=None)[source]

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.

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 spynnaker8.FixedNumberPreConnector(n, allow_self_connections=True, safe=True, verbose=False, with_replacement=False, rng=None, callback=None)[source]

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.

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 spynnaker8.FixedProbabilityConnector(p_connect, allow_self_connections=True, safe=True, verbose=False, rng=None, callback=None)[source]

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
class spynnaker8.FromFileConnector(file, distributed=False, safe=True, callback=None, verbose=False)[source]

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 spynnaker8.FromListConnector(conn_list, safe=True, verbose=False, column_names=None, callback=None)[source]

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 spynnaker8.IndexBasedProbabilityConnector(index_expression, allow_self_connections=True, rng=None, safe=True, callback=None, verbose=False)[source]

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
spynnaker8.FixedTotalNumberConnector

alias of spynnaker.pyNN.models.neural_projections.connectors.multapse_connector.MultapseConnector

class spynnaker8.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]

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 spynnaker8.OneToOneConnector(safe=True, callback=None, verbose=False)[source]

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 spynnaker8.SmallWorldConnector(degree, rewiring, allow_self_connections=True, n_connections=None, rng=None, safe=True, callback=None, verbose=False)[source]

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

spynnaker8.StaticSynapse

alias of spynnaker.pyNN.models.neuron.synapse_dynamics.synapse_dynamics_static.SynapseDynamicsStatic

spynnaker8.STDPMechanism

alias of spynnaker.pyNN.models.neuron.synapse_dynamics.synapse_dynamics_stdp.SynapseDynamicsSTDP

spynnaker8.AdditiveWeightDependence

alias of spynnaker.pyNN.models.neuron.plasticity.stdp.weight_dependence.weight_dependence_additive.WeightDependenceAdditive

spynnaker8.MultiplicativeWeightDependence

alias of spynnaker.pyNN.models.neuron.plasticity.stdp.weight_dependence.weight_dependence_multiplicative.WeightDependenceMultiplicative

spynnaker8.SpikePairRule

alias of spynnaker.pyNN.models.neuron.plasticity.stdp.timing_dependence.timing_dependence_spike_pair.TimingDependenceSpikePair

spynnaker8.StructuralMechanismStatic

alias of spynnaker.pyNN.models.neuron.synapse_dynamics.synapse_dynamics_structural_static.SynapseDynamicsStructuralStatic

spynnaker8.StructuralMechanismSTDP

alias of spynnaker.pyNN.models.neuron.synapse_dynamics.synapse_dynamics_structural_stdp.SynapseDynamicsStructuralSTDP

class spynnaker8.LastNeuronSelection(spike_buffer_size=64)[source]

Partner selection that picks a random source neuron from the neurons that spiked in the last timestep

Parameters:spike_buffer_size – The size of the buffer for holding spikes
get_parameter_names()[source]

Return the names of the parameters supported by this rule

Return type:iterable(str)
get_parameters_sdram_usage_in_bytes()[source]

Get the amount of SDRAM used by the parameters of this rule

Return type:str
vertex_executable_suffix

The suffix to be appended to the vertex executable for this rule

Return type:str
write_parameters(spec)[source]

Write the parameters of the rule to the spec

Parameters:spec (DataSpecificationGenerator) –
class spynnaker8.RandomSelection[source]

Partner selection that picks a random source neuron from all sources

get_parameter_names()[source]

Return the names of the parameters supported by this rule

Return type:iterable(str)
get_parameters_sdram_usage_in_bytes()[source]

Get the amount of SDRAM used by the parameters of this rule

Return type:str
vertex_executable_suffix

The suffix to be appended to the vertex executable for this rule

Return type:str
write_parameters(spec)[source]

Write the parameters of the rule to the spec

Parameters:spec (DataSpecificationGenerator) –
class spynnaker8.DistanceDependentFormation(grid=(16, 16), p_form_forward=0.16, sigma_form_forward=2.5, p_form_lateral=1.0, sigma_form_lateral=1.0)[source]

Formation rule that depends on the physical distance between neurons

Parameters:
  • grid (tuple(int,int) or list(int) or ndarray(int)) – (x, y) dimensions of the grid of distance
  • p_form_forward (float) – The peak probability of formation on feed-forward connections
  • sigma_form_forward (float) – The spread of probability with distance of formation on feed-forward connections
  • p_form_lateral (float) – The peak probability of formation on lateral connections
  • sigma_form_lateral (float) – The spread of probability with distance of formation on lateral connections
distance(x0, x1, metric)[source]

Compute the distance between points x0 and x1 place on the grid using periodic boundary conditions.

Parameters:
  • x0 (ndarray(int)) – first point in space
  • x1 (ndarray(int)) – second point in space
  • grid (ndarray(int)) – shape of grid
  • metric (str) – distance metric, i.e. euclidian or manhattan or equidistant
Returns:

the distance

Return type:

float

generate_distance_probability_array(probability, sigma)[source]

Generate the exponentially decaying probability LUTs.

Parameters:
  • probability (float) – peak probability
  • sigma (float) – spread
Returns:

distance-dependent probabilities

Return type:

ndarray(float)

get_parameter_names()[source]

Return the names of the parameters supported by this rule

Return type:iterable(str)
get_parameters_sdram_usage_in_bytes()[source]

Get the amount of SDRAM used by the parameters of this rule

Return type:int
vertex_executable_suffix

The suffix to be appended to the vertex executable for this rule

Return type:str
write_parameters(spec)[source]

Write the parameters of the rule to the spec

Parameters:spec (DataSpecificationGenerator) –
class spynnaker8.RandomByWeightElimination(threshold, prob_elim_depressed=0.0245, prob_elim_potentiated=0.00013600000000000003)[source]

Elimination Rule that depends on the weight of a synapse

Parameters:
  • threshold (float) – Below this weight is considered depression, above or equal to this weight is considered potentiation (or the static weight of the connection on static weight connections)
  • prob_elim_depressed (float) – The probability of elimination if the weight has been depressed (ignored on static weight connections)
  • prob_elim_potentiated (float) – The probability of elimination of the weight has been potentiated or has not changed (and also used on static weight connections)
get_parameter_names()[source]

Return the names of the parameters supported by this rule

Return type:iterable(str)
get_parameters_sdram_usage_in_bytes()[source]

Get the amount of SDRAM used by the parameters of this rule

Return type:int
vertex_executable_suffix

The suffix to be appended to the vertex executable for this rule

Return type:str
write_parameters(spec, weight_scale)[source]

Write the parameters of the rule to the spec

Parameters:
spynnaker8.IF_cond_exp

alias of spynnaker.pyNN.models.neuron.builds.if_cond_exp_base.IFCondExpBase

spynnaker8.IF_curr_exp

alias of spynnaker.pyNN.models.neuron.builds.if_curr_exp_base.IFCurrExpBase

spynnaker8.IF_curr_alpha

alias of spynnaker.pyNN.models.neuron.builds.if_curr_alpha.IFCurrAlpha

spynnaker8.IF_curr_delta

alias of spynnaker.pyNN.models.neuron.builds.if_curr_delta.IFCurrDelta

spynnaker8.Izhikevich

alias of spynnaker.pyNN.models.neuron.builds.izk_curr_exp_base.IzkCurrExpBase

class spynnaker8.SpikeSourceArray(spike_times=None)[source]
create_vertex(n_neurons, label, constraints, splitter)[source]

Create a vertex for a population of the model

Parameters:
  • n_neurons (int) – The number of neurons in the population
  • label (str) – The label to give to the vertex
  • constraints (list(AbstractConstraint) or None) – A list of constraints to give to the vertex, or None
Returns:

An application vertex for the population

Return type:

ApplicationVertex

class spynnaker8.SpikeSourcePoisson(rate=1.0, start=0, duration=None)[source]
create_vertex(n_neurons, label, constraints, seed, max_rate, splitter)[source]

Create a vertex for a population of the model

Parameters:
  • n_neurons (int) – The number of neurons in the population
  • label (str) – The label to give to the vertex
  • constraints (list(AbstractConstraint) or None) – A list of constraints to give to the vertex, or None
Returns:

An application vertex for the population

Return type:

ApplicationVertex

classmethod get_max_atoms_per_core()[source]

Get the maximum number of atoms per core for this model

Return type:int
classmethod set_model_max_atoms_per_core(n_atoms=500)[source]

Set the maximum number of atoms per core for this model

Parameters:n_atoms (int or None) – The new maximum, or None for the largest possible
class spynnaker8.Assembly(*populations, **kwargs)[source]

A group of neurons, may be heterogeneous, in contrast to a Population where all the neurons are of the same type.

Parameters:
  • populations (Population or PopulationView) – the populations or views to form the assembly out of
  • kwargs – may contain label (a string describing the assembly)

Create an Assembly of Populations and/or PopulationViews.

class spynnaker8.Population(size, cellclass, cellparams=None, structure=None, initial_values=None, label=None, constraints=None, additional_parameters=None)[source]

PyNN 0.9 population object.

Parameters:
  • size (int) – The number of neurons in the population
  • cellclass (type or AbstractPyNNModel) – The implementation of the individual neurons.
  • cellparams (dict(str,object) or None) – Parameters to pass to cellclass if it is a class to instantiate. Must be None if cellclass is an instantiated object.
  • structure (BaseStructure) –
  • initial_values (dict(str,float)) – Initial values of state variables
  • label (str) – A label for the population
  • constraints (list(AbstractConstraint)) – Any constraints on how the population is deployed to SpiNNaker.
  • additional_parameters (dict(str, ..)) – Additional parameters to pass to the vertex creation function.
add_placement_constraint(x, y, p=None)[source]

Add a placement constraint

Parameters:
  • x (int) – The x-coordinate of the placement constraint
  • y (int) – The y-coordinate of the placement constraint
  • p (int) – The processor ID of the placement constraint (optional)
all()[source]

Iterator over cell IDs on all MPI nodes.

Return type:iterable(IDMixin)
all_cells
Return type:list(IDMixin)
annotations

The annotations given by the end user

Return type:dict(str, ..)
can_record(variable)[source]

Determine whether variable can be recorded from this population.

Parameters:variable (str) – The variable to answer the question about
Return type:bool
celltype

Implements the PyNN expected celltype property

Returns:The celltype this property has been set to
Return type:AbstractPyNNModel
conductance_based

True if the population uses conductance inputs

Return type:bool
static create(cellclass, cellparams=None, n=1)[source]

Pass through method to the constructor defined by PyNN. Create n cells all of the same type.

Parameters:
Returns:

A New Population

Return type:

Population

describe(template='population_default.txt', engine='default')[source]

Returns a human-readable description of the population.

The output may be customized by specifying a different template together with an associated template engine (see pyNN.descriptions).

If template is None, then a dictionary containing the template context will be returned.

Parameters:
  • template (str) – Template filename
  • engine (str or TemplateEngine or None) – Template substitution engine
Return type:

str or dict

find_units(variable)[source]

Get the units of a variable

Parameters:variable (str) – The name of the variable
Returns:The units of the variable
Return type:str
first_id

The ID of the first member of the population.

Return type:int
get(parameter_names, gather=True, simplify=True)[source]

Get the values of a parameter for every local cell in the population.

Parameters:
  • parameter_names (str or iterable(str)) – Name of parameter. This is either a single string or a list of strings
  • gather (bool) – pointless on sPyNNaker
  • simplify (bool) – ignored
Returns:

A single list of values (or possibly a single value) if paramter_names is a string, or a dict of these if parameter names is a list.

Return type:

str or list(str) or dict(str,str) or dict(str,list(str))

get_data(variables='all', gather=True, clear=False, annotations=None)[source]

Return a Neo Block containing the data (spikes, state variables) recorded from the Assembly.

Parameters:
  • variables (str or list(str)) – either a single variable name or a list of variable names. Variables must have been previously recorded, otherwise an Exception will be raised.
  • gather (bool) –

    Whether to collect data from all MPI nodes or just the current node.

    Note

    This is irrelevant on sPyNNaker, which always behaves as if this parameter is True.

  • clear (bool) – Whether recorded data will be deleted from the Assembly.
  • annotations (dict(str, ..)) – annotations to put on the neo block
Return type:

Block

Raises:

ConfigurationException – If the variable or variables have not been previously set to record.

get_data_by_indexes(variables, indexes, clear=False, annotations=None)[source]

Return a Neo Block containing the data (spikes, state variables) recorded from the Assembly.

Parameters:
  • variables (str or list(str)) – either a single variable name or a list of variable names. Variables must have been previously recorded, otherwise an Exception will be raised.
  • indexes (list(int)) – List of neuron indexes to include in the data. Clearly only neurons recording will actually have any data. If None will be taken as all recording as in get_data()
  • clear (bool) – Whether recorded data will be deleted.
  • annotations (dict(str, ..)) – annotations to put on the neo block
Return type:

Block

Raises:

ConfigurationException – If the variable or variables have not been previously set to record.

get_initial_value(variable, selector=None)[source]

Deprecated since version 6.0: Use initial_values() instead.

get_spike_counts(gather=True)[source]

Return the number of spikes for each neuron.

Return type:ndarray
id_to_index(id)[source]

Given the ID(s) of cell(s) in the Population, return its (their) index (order in the Population).

Defined by http://neuralensemble.org/docs/PyNN/reference/populations.html

Parameters:id (int or iterable(int)) –
Return type:int or iterable(int)
id_to_local_index(cell_id)[source]

Given the ID(s) of cell(s) in the Population, return its (their) index (order in the Population), counting only cells on the local MPI node.

Defined by http://neuralensemble.org/docs/PyNN/reference/populations.html

Parameters:cell_id (int or iterable(int)) –
Return type:int or iterable(int)
index_to_id(index)[source]

Given the index (order in the Population) of cell(s) in the Population, return their ID(s)

Parameters:index (int or iterable(int)) –
Return type:int or iterable(int)
initial_values
Return type:dict
initialize(**kwargs)[source]

Set initial values of state variables, e.g. the membrane potential. Values passed to initialize() may be:

  • single numeric values (all neurons set to the same value), or
  • RandomDistribution objects, or
  • lists / arrays of numbers of the same size as the population mapping functions, where a mapping function accepts a single argument (the cell index) and returns a single number.

Values should be expressed in the standard PyNN units (i.e. millivolts, nanoamps, milliseconds, microsiemens, nanofarads, event per second).

Examples:

p.initialize(v=-70.0)
p.initialize(v=rand_distr, gsyn_exc=0.0)
p.initialize(v=lambda i: -65 + i / 10.0)
inject(current_source)[source]

Connect a current source to all cells in the Population.

Defined by http://neuralensemble.org/docs/PyNN/reference/populations.html

label

The label of the population

Return type:str
last_id

The ID of the last member of the population.

Return type:int
local_size

The number of local cells

Defined by http://neuralensemble.org/docs/PyNN/reference/populations.html

mark_no_changes()[source]

Mark this population as not having changes to be mapped.

position_generator
Return type:callable((int), ndarray)
positions

Return the position array for structured populations.

Returns:a 2D array, one row per cell. Each row is three long, for X,Y,Z
Return type:ndarray
record(variables, to_file=None, sampling_interval=None)[source]

Record the specified variable or variables for all cells in the Population or view.

Parameters:
  • variables (str or list(str)) – either a single variable name or a list of variable names. For a given celltype class, celltype.recordable contains a list of variables that can be recorded for that celltype.
  • to_file (io or rawio or str) – a file to automatically record to (optional). write_data() will be automatically called when sim.end() is called.
  • sampling_interval (int) – a value in milliseconds, and an integer multiple of the simulation timestep.
requires_mapping

Whether this population requires mapping.

Return type:bool
sample(n, rng=None)[source]

Randomly sample n cells from the Population, and return a PopulationView object.

Parameters:
  • n (int) – The number of cells to put in the view.
  • rng (NumpyRNG) – The random number generator to use
Return type:

PopulationView

set(**parameters)[source]

Set parameters of this population.

Parameters:parameters – The parameters to set.
set_by_selector(selector, parameter, value=None)[source]

Set one or more parameters for selected cell in the population.

param can be a dict, in which case value should not be supplied, or a string giving the parameter name, in which case value is the parameter value. value can be a numeric value, or list of such (e.g. for setting spike times):

p.set_by_selector(1, "tau_m", 20.0).
p.set_by_selector(1, {'tau_m':20, 'v_rest':-65})
Parameters:
  • selector – See RangedList.set_value_by_selector() as this is just a pass through method
  • parameter (str or dict(str, int or float or list(int) or list(float))) – the parameter to set or dictionary of parameters to set
  • value (int or float or list(int) or list(float)) – the value of the parameter to set.
set_constraint(constraint)[source]

Apply a constraint to a population that restricts the processor onto which its atoms will be placed.

Parameters:constraint (AbstractConstraint) –
set_initial_value(variable, value, selector=None)[source]

Deprecated since version 6.0: Use initialize() instead.

set_mapping_constraint(constraint_dict)[source]

Add a placement constraint - for backwards compatibility

Parameters:constraint_dict (dict(str,int)) – A dictionary containing “x”, “y” and optionally “p” as keys, and ints as values
set_max_atoms_per_core(max_atoms_per_core)[source]

Supports the setting of this population’s max atoms per core

Parameters:max_atoms_per_core (int) – the new value for the max atoms per core.
size

The number of neurons in the population

Return type:int
spinnaker_get_data(variable)[source]

Public accessor for getting data as a numpy array, instead of the neo based object

Parameters:variable (str or list(str)) – either a single variable name or a list of variable names. Variables must have been previously recorded, otherwise an Exception will be raised.
Returns:array of the data
Return type:ndarray
structure

Return the structure for the population.

Return type:BaseStructure or None
tset(**kwargs)[source]

Deprecated since version 5.0: Use set(parametername=value_array) instead.

write_data(io, variables='all', gather=True, clear=False, annotations=None)[source]

Write recorded data to file, using one of the file formats supported by Neo.

Parameters:
  • io (neo.io.baseio.BaseIO or str) – a Neo IO instance, or a string for where to put a neo instance
  • variables (str or list(str)) – either a single variable name or a list of variable names. Variables must have been previously recorded, otherwise an Exception will be raised.
  • gather (bool) –

    Whether to bring all relevant data together.

    Note

    SpiNNaker always gathers.

  • clear (bool) – clears the storage data if set to true after reading it back
  • annotations (dict(str, ..)) – annotations to put on the neo block
Raises:

ConfigurationException – If the variable or variables have not been previously set to record.

class spynnaker8.PopulationView(parent, selector, label=None)[source]

A view of a subset of neurons within a Population.

In most ways, Populations and PopulationViews have the same behaviour, i.e., they can be recorded, connected with Projections, etc. It should be noted that any changes to neurons in a PopulationView will be reflected in the parent Population and vice versa.

It is possible to have views of views.

Note

Selector to Id is actually handled by AbstractSized.

Parameters:
  • parent (Population or PopulationView) – the population or view to make the view from
  • selector (None or slice or int or list(bool) or list(int) or ndarray(bool) or ndarray(int)) –

    a slice or numpy mask array. The mask array should either be a boolean array (ideally) of the same size as the parent, or an integer array containing cell indices, i.e. if p.size == 5 then:

    PopulationView(p, array([False, False, True, False, True]))
    PopulationView(p, array([2, 4]))
    PopulationView(p, slice(2, 5, 2))
    

    will all create the same view.

  • label (str) – A label for the view
all()[source]

Iterator over cell IDs (on all MPI nodes).

Return type:iterable(IDMixin)
all_cells

An array containing the cell IDs of all neurons in the Population (all MPI nodes).

Return type:list(IDMixin)
can_record(variable)[source]

Determine whether variable can be recorded from this population.

Return type:bool
celltype

The type of neurons making up the underlying Population.

Return type:AbstractPyNNModel
conductance_based

Indicates whether the post-synaptic response is modelled as a change in conductance or a change in current.

Return type:bool
describe(template='populationview_default.txt', engine='default')[source]

Returns a human-readable description of the population view.

The output may be customized by specifying a different template together with an associated template engine (see pyNN.descriptions).

If template is None, then a dictionary containing the template context will be returned.

Parameters:
  • template (str) – Template filename
  • engine (str or TemplateEngine or None) – Template substitution engine
Return type:

str or dict

find_units(variable)[source]

Get the units of a variable

Warning

No PyNN description of this method.

Parameters:variable (str) – The name of the variable
Returns:The units of the variable
Return type:str
get(parameter_names, gather=False, simplify=True)[source]

Get the values of the given parameters for every local cell in the population, or, if gather=True, for all cells in the population.

Values will be expressed in the standard PyNN units (i.e. millivolts, nanoamps, milliseconds, microsiemens, nanofarads, event per second).

Note

SpiNNaker always gathers.

Parameters:
Return type:

iterable(float)

get_data(variables='all', gather=True, clear=False, annotations=None)[source]

Return a Neo Block containing the data(spikes, state variables) recorded from the Population.

Parameters:
  • variables (str or list(str)) – Either a single variable name or a list of variable names. Variables must have been previously recorded, otherwise an Exception will be raised.
  • gather (bool) –

    For parallel simulators, if gather is True, all data will be gathered to all nodes and the Neo Block will contain data from all nodes. Otherwise, the Neo Block will contain only data from the cells simulated on the local node.

    Note

    SpiNNaker always gathers.

  • clear (bool) – If True, recorded data will be deleted from the Population.
  • annotations (dict(str, ..)) – annotations to put on the neo block
Return type:

Block

Raises:

ConfigurationException – If the variable or variables have not been previously set to record.

get_spike_counts(gather=True)[source]

Returns a dict containing the number of spikes for each neuron.

The dict keys are neuron IDs, not indices.

Note

Implementation of this method is different to Population as the Populations uses PyNN 7 version of the get_spikes method which does not support indexes.

Parameters:gather (bool) –

Note

SpiNNaker always gathers.

Return type:dict(int,int)
grandparent

Returns the parent Population at the root of the tree (since the immediate parent may itself be a PopulationView).

The name “grandparent” is of course a little misleading, as it could be just the parent, or the great, great, great, …, grandparent.

Return type:Population
id_to_index(id)[source]

Given the ID(s) of cell(s) in the PopulationView, return its / their index / indices(order in the PopulationView).

assert pv.id_to_index(pv[3]) == 3

Parameters:id (int or list(int)) –
Return type:int or list(int)
index_in_grandparent(indices)[source]

Given an array of indices, return the indices in the parent population at the root of the tree.

Parameters:indices (list(int)) –
Return type:list(int)
initial_values

A dict containing the initial values of the state variables.

Return type:dict(str, ..)
initialize(**initial_values)[source]

Set initial values of state variables, e.g. the membrane potential. Values passed to initialize() may be:

  • single numeric values (all neurons set to the same value), or
  • RandomDistribution objects, or
  • lists / arrays of numbers of the same size as the population mapping functions, where a mapping function accepts a single argument (the cell index) and returns a single number.

Values should be expressed in the standard PyNN units (i.e. millivolts, nanoamps, milliseconds, microsiemens, nanofarads, events per second).

Examples:

p.initialize(v=-70.0)
p.initialize(v=rand_distr, gsyn_exc=0.0)
p.initialize(v=lambda i: -65 + i / 10.0)
label

A label for the Population View.

Return type:str
mask

The selector mask that was used to create this view.

Return type:None or slice or int or list(bool) or list(int) or ndarray(bool) or ndarray(int)
parent

A reference to the parent Population (that this is a view of).

Return type:Population
record(variables, to_file=None, sampling_interval=None)[source]

Record the specified variable or variables for all cells in the Population or view.

Parameters:
  • variables (str or list(str)) – either a single variable name, or a list of variable names, or all to record everything. For a given celltype class, celltype.recordable contains a list of variables that can be recorded for that celltype.
  • to_file (io or rawio or str) – If specified, should be a Neo IO instance and write_data() will be automatically called when sim.end() is called.
  • sampling_interval (int) – should be a value in milliseconds, and an integer multiple of the simulation timestep.
sample(n, rng=None)[source]

Randomly sample n cells from the Population view, and return a new PopulationView object.

Parameters:
  • n (int) – The number of cells to select
  • rng (NumpyRNG) – Random number generator
Return type:

PopulationView

set(**parameters)[source]

Set one or more parameters for every cell in the population. Values passed to set() may be:

  • single values,
  • RandomDistribution objects, or
  • lists / arrays of values of the same size as the population mapping functions, where a mapping function accepts a single argument (the cell index) and returns a single value.

Here, a “single value” may be either a single number or a list / array of numbers (e.g. for spike times).

Values should be expressed in the standard PyNN units (i.e. millivolts, nanoamps, milliseconds, microsiemens, nanofarads, event per second).

Examples:

p.set(tau_m=20.0, v_rest=-65).
p.set(spike_times=[0.3, 0.7, 0.9, 1.4])
p.set(cm=rand_distr, tau_m=lambda i: 10 + i / 10.0)
size

The total number of neurons in the Population View.

Return type:int
write_data(io, variables='all', gather=True, clear=False, annotations=None)[source]

Write recorded data to file, using one of the file formats supported by Neo.

Parameters:
  • io (neo.io.BaseIO or str) – a Neo IO instance or the name of a file to write
  • variables (str or list(str)) – either a single variable name or a list of variable names. These must have been previously recorded, otherwise an Exception will be raised.
  • gather (bool) –

    For parallel simulators, if this is True, all data will be gathered to the master node and a single output file created there. Otherwise, a file will be written on each node, containing only data from the cells simulated on that node.

    Note

    SpiNNaker always gathers.

  • clear (bool) – If this is True, recorded data will be deleted from the Population.
  • annotations (dict(str, ..)) – should be a dict containing simple data types such as numbers and strings. The contents will be written into the output data file as metadata.
Raises:

ConfigurationException – If the variable or variables have not been previously set to record.

spynnaker8.SpiNNakerProjection

alias of spynnaker.pyNN.models.projection.Projection

spynnaker8.end(_=True)[source]

Cleans up the SpiNNaker machine and software

Parameters:_ – was named compatible_output, which we don’t care about, so is a non-existent parameter
spynnaker8.setup(timestep=0.1, min_delay='auto', max_delay='auto', graph_label=None, database_socket_addresses=None, extra_algorithm_xml_paths=None, extra_mapping_inputs=None, extra_mapping_algorithms=None, extra_pre_run_algorithms=None, extra_post_run_algorithms=None, extra_load_algorithms=None, time_scale_factor=None, n_chips_required=None, n_boards_required=None, **extra_params)[source]

The main method needed to be called to make the PyNN 0.8 setup. Needs to be called before any other function

Parameters:
  • timestep (float or None) – the time step of the simulations in micro seconds if None the cfg value is used
  • min_delay (float or str) – the min delay of the simulation
  • max_delay (float or str) – the max delay of the simulation
  • graph_label (str or None) – the label for the graph
  • database_socket_addresses (iterable(SocketAddress)) – the sockets used by external devices for the database notification protocol
  • extra_algorithm_xml_paths (list(str) or None) – list of paths to where other XML are located
  • extra_mapping_inputs (dict(str, Any) or None) – other inputs used by the mapping process
  • extra_mapping_algorithms (list(str) or None) – other algorithms to be used by the mapping process
  • extra_pre_run_algorithms (list(str) or None) – extra algorithms to use before a run
  • extra_post_run_algorithms (list(str) or None) – extra algorithms to use after a run
  • extra_load_algorithms (list(str) or None) – extra algorithms to use within the loading phase
  • time_scale_factor (int or None) – multiplicative factor to the machine time step (does not affect the neuron models accuracy)
  • n_chips_required (int or None) – Deprecated! Use n_boards_required instead. Must be None if n_boards_required specified.
  • n_boards_required (int or None) – if you need to be allocated a machine (for spalloc) before building your graph, then fill this in with a general idea of the number of boards you need so that the spalloc system can allocate you a machine big enough for your needs.
  • extra_params – other keyword argumets used to configure PyNN
Returns:

MPI rank (always 0 on SpiNNaker)

Return type:

int

Raises:

ConfigurationException – if both n_chips_required and n_boards_required are used.

spynnaker8.run(simtime, callbacks=None)[source]

The run() function advances the simulation for a given number of milliseconds, e.g.:

Parameters:
  • simtime (float) – time to run for (in milliseconds)
  • callbacks – callbacks to run
Returns:

the actual simulation time that the simulation stopped at

Return type:

float

spynnaker8.run_until(tstop)[source]

Run until a (simulation) time period has completed.

Parameters:tstop (float) – the time to stop at (in milliseconds)
Returns:the actual simulation time that the simulation stopped at
Return type:float
spynnaker8.run_for(simtime, callbacks=None)

The run() function advances the simulation for a given number of milliseconds, e.g.:

Parameters:
  • simtime (float) – time to run for (in milliseconds)
  • callbacks – callbacks to run
Returns:

the actual simulation time that the simulation stopped at

Return type:

float

spynnaker8.num_processes()[source]

The number of MPI processes.

Note

Always 1 on SpiNNaker, which doesn’t use MPI.

Returns:the number of MPI processes
Return type:int
spynnaker8.rank()[source]

The MPI rank of the current node.

Note

Always 0 on SpiNNaker, which doesn’t use MPI.

Returns:MPI rank
Return type:int
spynnaker8.reset(annotations=None)[source]

Resets the simulation to t = 0

Parameters:annotations (dict(str, ..)) – the annotations to the data objects
Return type:None
spynnaker8.set_number_of_neurons_per_core(neuron_type, max_permitted)[source]

Sets a ceiling on the number of neurons of a given type that can be placed on a single core.

Parameters:
spynnaker8.get_projections_data(projection_data)[source]
Parameters:projection_data (dict(Projection, list(int) or tuple(int) or None)) – the projection to attributes mapping
Returns:a extracted data object with get method for getting the data
Return type:ExtractedData
spynnaker8.Projection(presynaptic_population, postsynaptic_population, connector, synapse_type=None, source=None, receptor_type='excitatory', space=None, label=None)[source]

Used to support PEP 8 spelling correctly

Parameters:
Returns:

a projection object for SpiNNaker

Return type:

Projection

spynnaker8.get_current_time()[source]

Gets the time within the simulation

Returns:returns the current time
spynnaker8.create(cellclass, cellparams=None, n=1)[source]

Builds a population with certain params

Parameters:
Return type:

Population

spynnaker8.connect(pre, post, weight=0.0, delay=None, receptor_type=None, p=1, rng=None)[source]

Builds a projection

Parameters:
  • pre (Population) – source pop
  • post (Population) – destination pop
  • weight (float) – weight of the connections
  • delay (float) – the delay of the connections
  • receptor_type (str) – excitatory / inhibitory
  • p (float) – probability
  • rng (NumpyRNG) – random number generator
spynnaker8.get_time_step()[source]

The integration time step

Returns:get the time step of the simulation (in ms)
Return type:float
spynnaker8.get_min_delay()[source]

The minimum allowed synaptic delay; delays will be clamped to be at least this.

Returns:returns the min delay of the simulation
Return type:int
spynnaker8.get_max_delay()[source]

The maximum allowed synaptic delay; delays will be clamped to be at most this.

Returns:returns the max delay of the simulation
Return type:int
spynnaker8.initialize(cells, **initial_values)[source]

Sets cells to be initialised to the given values

Parameters:
  • cells (Population or PopulationView) – the cells to change params on
  • initial_values – the params and their values to change
spynnaker8.list_standard_models()[source]

Return a list of all the StandardCellType classes available for this simulator.

Return type:list(str)
spynnaker8.name()[source]

Returns the name of the simulator

Return type:str
spynnaker8.record(variables, source, filename, sampling_interval=None, annotations=None)[source]

Sets variables to be recorded.

Parameters:
  • variables (str or list(str)) – may be either a single variable name or a list of variable names. For a given celltype class, celltype.recordable contains a list of variables that can be recorded for that celltype.
  • source (Population or PopulationView) – where to record from
  • filename (str) – file name to write data to
  • sampling_interval – how often to sample the recording, not ignored so far
  • annotations (dict(str, ..)) – the annotations to data writers
Returns:

neo object

Return type:

Block

spynnaker8.record_v(source, filename)[source]

Deprecated method for getting voltage. This is not documented in the public facing API.

Deprecated since version 5.0.

Parameters:
Return type:

None

spynnaker8.record_gsyn(source, filename)[source]

Deprecated method for getting both types of gsyn. This is not documented in the public facing API

Deprecated since version 5.0.

Parameters:

Indices and tables