spynnaker.pyNN.models package

Subpackages

Submodules

spynnaker.pyNN.models.abstract_pynn_model module

class spynnaker.pyNN.models.abstract_pynn_model.AbstractPyNNModel[source]

Bases: object

A Model that can be passed in to a Population object in PyNN.

absolute_max_atoms_per_core = 9223372036854775807
abstract create_vertex(n_neurons, label)[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

Returns:

An application vertex for the population

Return type:

PopulationApplicationVertex

default_initial_values = {}
default_parameters = {}
abstract property default_population_parameters

The default values for the parameters at the population level. These are parameters that can be passed in to the Population constructor in addition to the standard PyNN options.

Return type:

dict(str, Any)

describe(template='modeltype_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

classmethod get_model_max_atoms_per_dimension_per_core()[source]

Get the maximum number of atoms per dimension per core for this model.

Return type:

int or tuple or None

classmethod get_parameter_names()[source]

Get the names of the parameters of the model.

Return type:

list(str)

classmethod has_parameter(name)[source]

Determine if the model has a parameter with the given name.

Parameters:

name (str) – The name of the parameter to check for

Return type:

bool

property name

The name of this model.

Return type:

str

classmethod set_model_max_atoms_per_dimension_per_core(n_atoms=None)[source]

Set the default maximum number of atoms per dimension per core for this model. This can be overridden by the individual Population. The new value can be None, meaning that the maximum is the same as the number of atoms, an int, meaning all Populations of this model must have one dimension, or a tuple of n integers, meaning all Populations of this model must have n dimensions. If not all Populations of this model have the same number of dimensions, it is recommended to set this to None here and then set the maximum on each Population.

Parameters:

n_atoms (int or tuple or None) – The new maximum, or None for the largest possible

spynnaker.pyNN.models.defaults module

spynnaker.pyNN.models.defaults.default_initial_values(state_variables)[source]

Specifies arguments which are state variables. Only works on the __init__ method of a class that is additionally decorated with defaults()

Parameters:

state_variables (iterable(str)) – The names of the arguments that are state variables

spynnaker.pyNN.models.defaults.default_parameters(parameters)[source]

Specifies arguments which are parameters. Only works on the __init__ method of a class that is additionally decorated with defaults()

Parameters:

parameters (iterable(str)) – The names of the arguments that are parameters

spynnaker.pyNN.models.defaults.get_dict_from_init(init_method, skip=None, include=None)[source]

Get an argument initialisation dictionary by examining an __init__ method or function.

Parameters:
  • init_method (callable) – The method.

  • skip (frozenset(str)) – The arguments to be skipped, if any

  • include (frozenset(str)) – The arguments that must be present, if any

Returns:

an initialisation dictionary

Return type:

dict(str, Any)

spynnaker.pyNN.models.projection module

class spynnaker.pyNN.models.projection.Projection(pre_synaptic_population, post_synaptic_population, connector, synapse_type=None, source=None, receptor_type=None, space=None, label=None)[source]

Bases: object

A container for all the connections of a given type (same synapse type and plasticity mechanisms) between two populations, together with methods to set parameters of those connections, including of plasticity mechanisms.

Parameters:
get(attribute_names, format, gather=True, with_address=True, multiple_synapses='last')[source]

Get a parameter/attribute of the projection.

Note

SpiNNaker always gathers.

Parameters:
  • attribute_names (str or iterable(str)) – list of attributes to gather

  • format (str) – "list" or "array"

  • gather (bool) – gather over all nodes

  • with_address (bool) – True if the source and target are to be included

  • multiple_synapses (str) – What to do with the data if format=”array” and if the multiple source-target pairs with the same values exist. Currently only “last” is supported

Returns:

values selected

property label
Return type:

str

property post

The post-population or population view.

Return type:

PopulationBase

property pre

The pre-population or population view.

Return type:

PopulationBase

save(attribute_names, file, format='list', gather=True, with_address=True)[source]

Print synaptic attributes (weights, delays, etc.) to file. In the array format, zeros are printed for non-existent connections. Values will be expressed in the standard PyNN units (i.e., millivolts, nanoamps, milliseconds, microsiemens, nanofarads, event per second).

Note

SpiNNaker always gathers.

Parameters:
  • attribute_names (str or list(str)) –

  • file (str or pyNN.recording.files.BaseFile) – filename or open handle (which will be closed)

  • format (str) –

  • gather (bool) – Ignored

  • with_address (bool) –

set(**attributes)[source]

Warning

Not implemented.

size(gather=True)[source]

Return the total number of connections.

Note

SpiNNaker always gathers.

Warning

Not implemented.

Parameters:

gather (bool) – If False, only get the number of connections locally.

spynnaker.pyNN.models.recorder module

class spynnaker.pyNN.models.recorder.Recorder(population, vertex)[source]

Bases: object

Object to hold recording behaviour, used by populations.

Parameters:
  • population (Population) – the population to record for

  • vertex (ApplicationVertex) – the SpiNNaker graph vertex used by the population

cache_data()[source]

Store data for later extraction.

csv_neo_block(csv_file, variables, view_indexes=None, annotations=None)[source]

Extracts block from the vertices and puts them into a Neo block.

Parameters:
  • variables (list(str)) – the variables to extract

  • variables – the variables to extract

  • view_indexes (slice) – the indexes to be included in the view

  • annotations (dict(str,object)) – annotations to put on the Neo block

Returns:

The Neo block

Return type:

Block

Raises:

ConfigurationException – If the recording not setup correctly

extract_neo_block(variables, view_indexes, clear, annotations)[source]

Extracts block from the vertices and puts them into a Neo block.

Parameters:
  • variables (list(str)) – the variables to extract

  • view_indexes (slice) – the indexes to be included in the view

  • clear (bool) – if the variables should be cleared after reading

  • annotations (dict(str,object)) – annotations to put on the Neo block

Returns:

The Neo block

Return type:

Block

Raises:

ConfigurationException – If the recording not setup correctly

record(variables, to_file, sampling_interval, indexes)[source]

Turns on (or off) recording.

Parameters:
  • variables (str or list(str) or None) – 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. Can also be None to reset the list of variables.

  • 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.

  • indexes (None or list(int)) – The indexes of neurons to record from. This is non-standard PyNN and equivalent to creating a view with these indexes and asking the View to record.

property recording_label
turn_off_all_recording(indexes=None)[source]

Turns off recording, is used by a pop saying .record().

Parameters:

indexes (list or None) –

turn_on_record(variable, sampling_interval=None, to_file=None, indexes=None)[source]

Tell the vertex to record data.

Parameters:
  • variable (str) – The variable to record, supported variables to record are: gsyn_exc, gsyn_inh, v, spikes.

  • sampling_interval (int) – the interval to record them

  • to_file (neo.io.baseio.BaseIO or str or None) – If set, a file to write to (by handle or name)

  • indexes (list(int) or None) – List of indexes to record or None for all

Raises:
  • SimulatorRunningException – If sim.run is currently running

  • SimulatorNotSetupException – If called before sim.setup

  • SimulatorShutdownException – If called after sim.end

property write_to_files_indicators

What variables should be written to files, and where should they be written.

Return type:

dict(str, neo.io.baseio.BaseIO or str or None)

Module contents