spynnaker.pyNN.models.spike_source package

Submodules

spynnaker.pyNN.models.spike_source.spike_source_array_machine_vertex module

class spynnaker.pyNN.models.spike_source.spike_source_array_machine_vertex.SpikeSourceArrayMachineVertex(label: str | None, vertex_slice: Slice | None = None, app_vertex: ReverseIpTagMultiCastSource | None = None, n_keys: int | None = None, eieio_params: EIEIOParameters | None = None, send_buffer_times: _SendBufferTimes = None)[source]

Bases: ReverseIPTagMulticastSourceMachineVertex

Extended to add colour.

Parameters:
  • label – The optional name of the vertex

  • vertex_slice – The slice of the application vertex that this machine vertex implements.

  • app_vertex – The application vertex that caused this machine vertex to be created. If None, there is no such application vertex.

  • n_keys – Number of keys. Only used to create a slice if vertex_slice is None.

  • eieio_params – Parameters to override the defaults

  • send_buffer_times – Times to spike at

get_n_keys_for_partition(partition_id: str) int[source]

Get the number of keys required by the given partition of edges.

Parameters:

partition_id – The identifier of the partition; the partition_id param is only used by some MachineVertex subclasses

Returns:

The number of keys required

Module contents

class spynnaker.pyNN.models.spike_source.SpikeSourceArray(*args: Any, **kwargs: Any)

Bases: AbstractPyNNModel

Model that creates a Spike Source Array Vertex

Parameters:

spike_times – Timesteps on which to spike

create_vertex(n_neurons: int, label: str, *, splitter: AbstractSplitterCommon | None = None, neurons_per_core: int | Tuple[int, ...] | None = None, n_colour_bits: int | None = None) SpikeSourceArrayVertex[source]

Create a vertex for a population of the model.

Parameters:
  • n_neurons – The number of neurons in the population

  • label – The label to give to the vertex

  • splitter

  • n_colour_bits

Returns:

An application vertex for the population

default_population_parameters: Dict[str, Any] = {'n_colour_bits': None, 'neurons_per_core': None, 'splitter': None}

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.

class spynnaker.pyNN.models.spike_source.SpikeSourceArrayVertex(n_neurons: int, spike_times: Spikes, label: str, max_atoms_per_core: int | Tuple[int, ...], model: SpikeSourceArray, splitter: AbstractSplitterCommon | None, n_colour_bits: int | None)

Bases: ReverseIpTagMultiCastSource, PopulationApplicationVertex, SupportsStructure

Model for play back of spikes.

Parameters:
  • n_neurons – The number of neurons in the population

  • spike_times – Timesteps on which to spike

  • label

  • max_atoms_per_core

  • model

  • splitter

  • n_colour_bits

SPIKE_RECORDING_REGION_ID = 0
property atoms_shape: Tuple[int, ...]

The “shape” of the atoms in the vertex i.e. how the atoms are split between the dimensions of the vertex. By default everything is 1-dimensional, so the value will be a 1-tuple but can be overridden by a vertex that supports multiple dimensions.

create_machine_vertex(vertex_slice: Slice, sdram: AbstractSDRAM, label: str | None = None) SpikeSourceArrayMachineVertex[source]

Create a machine vertex from this application vertex.

Parameters:
  • vertex_slice – The slice of atoms that the machine vertex will cover.

  • sdram – The SDRAM used by the machine vertex.

  • label – human readable label for the machine vertex

Returns:

The created machine vertex

describe() Dict[str, str | ParameterHolder | Dict[str, Any]][source]

Returns a human-readable description of the cell or synapse type.

The output may be customised 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.

Returns:

A human-readable description of the cell

get_buffer_data_type(name: str) BufferDataType[source]

Get the type of data recorded by the buffer manager.

The buffer data type controls how data returned by the cores is handled in NeoBufferDatabase.

Parameters:

name – The name of the variable recorded

Raises:

KeyError – if the variable isn’t being recorded

Returns:

Data type in the Buffer Database

get_data_type(name: str) None[source]

Get the type data returned by a recording of the variable.

This is the type of data the C code is returning. For instance data such as spikes this will be None.

Parameters:

name – The name of the variable to get the type of

Returns:

The data type used by the C code

Raises:

KeyError – If the variable isn’t recordable

get_neurons_recording(name: str, vertex_slice: Slice) ndarray[tuple[Any, ...], dtype[integer]][source]

Gets the neurons being recorded on the core with this slice.

Typically vertex_slice.get_raster_ids(atoms_shape) but may be a sublist if doing selective recording.

Parameters:
  • name – The name of the variable to get the region of

  • vertex_slice

Returns:

A list of the global raster IDs of the atoms in recording named variable within this slice

get_parameter_values(names: str | List[str] | Tuple[str, ...], selector: None | int | integer | SupportsInt | slice | Sequence[bool | bool] | Sequence[int | integer | SupportsInt] = None) ParameterHolder[source]
Parameters:
  • names – The name or names of the parameter to get

  • selector – a description of the subrange to accept, or None for all. See: selector_to_ids()

Returns:

The values of a parameter or parameters for the whole Population or a subset if the selector is used.

Raises:

KeyError – if the parameter is not something that can be read

get_parameters() List[str][source]
Returns:

The names of all the parameters that can be obtained

get_recordable_variables() List[str][source]

Get a list of the names of things that can be recorded.

This methods list the variable recorded via the Population.

Includes both neuron and synapse recordable things

Returns:

List of variable names

get_recording_region(name: str) int[source]
Parameters:

name – The name of the variable to get the region of

Returns:

The recording region for the named variable.

Raises:

KeyError – If the variable isn’t being recorded

get_recording_variables() List[str][source]
Returns:

A list of variables that are currently being recorded.

get_sampling_interval_ms(name: str) float[source]

Get the sampling interval of the recording for the given variable.

The values is in ms and unless selective recording is used will be SpynnakerDataView.get_simulation_time_step_us()

Parameters:

name – The name of the variable

Returns:

Sampling rate in milliseconds for this variable

Raises:

KeyError – If the variable isn’t being recorded

get_units(name: str) str[source]

Get the units of the given parameter or state variable.

Parameters:

name – the name of the parameter to get the units of

Returns:

The unit or this variable. For example ‘mV’ or ‘uS’. Will be an empty string for things like spikes and probability

Raises:

KeyError – if the name isn’t recognised or the units cannot be identified

property n_colour_bits: int

The number of colour bits sent by this vertex.

Assumed 0 unless overridden

set_not_recording(name: str, indices: Collection[int] | None = None) None[source]

Set a variable not recording.

Parameters:
  • name – The name of the variable to not record

  • indices – The list of neuron indices to not record or None for all

Raises:

KeyError – if the variable cannot be stopped from recording

set_parameter_values(name: str, value: float | Sequence[float] | ndarray[tuple[Any, ...], dtype[floating]] | RandomDistribution | int | Sequence[int] | Sequence[Sequence[int]] | ndarray[tuple[Any, ...], dtype[integer]], selector: None | int | integer | SupportsInt | slice | Sequence[bool | bool] | Sequence[int | integer | SupportsInt] = None) None[source]

Set the values of a parameter for the whole Population or a subset if the selector is used.

Parameters:
  • name – The name of the parameter to set

  • value – The new value

  • selector – a description of the subrange to accept, or None for all. See: selector_to_ids()

Raises:

KeyError – if the parameter is not something that can be changed

set_recording(name: str, sampling_interval: float | None = None, indices: Collection[int] | None = None) None[source]

Set a variable recording.

Parameters:
  • name – The name of the variable to set the status of

  • sampling_interval – How often the variable should be recorded or None for every time step, in milliseconds

  • indices – The list of neuron indices to record or None for all

Raises:

KeyError – if the variable cannot be recorded

set_structure(structure: BaseStructure) None[source]

Set the structure of the object.

Parameters:

structure – The structure to set

class spynnaker.pyNN.models.spike_source.SpikeSourceFromFile(*args: Any, **kwargs: Any)

Bases: SpikeSourceArray

A spike source that works from a file (typically a tab-separated table in a text file).

Parameters:
  • spike_time_file – absolute path to a file containing spike values

  • min_atom – min neuron ID to which neurons to read in

  • max_atom – max neuron ID to which neurons to read in

  • min_time – min time slot to read neurons values of.

  • max_time – max time slot to read neurons values of.

  • split_value – the pattern to split by

property spike_times: ndarray[tuple[Any, ...], dtype[integer]]

The spike times read from the file.

class spynnaker.pyNN.models.spike_source.SpikeSourcePoisson(*args: Any, **kwargs: Any)

Bases: AbstractPyNNModel

A model of a Poisson-distributed source of spikes.

Parameters:
  • rate

  • start

  • duration

absolute_max_atoms_per_core = 500
create_vertex(n_neurons: int, label: str, *, seed: int | None = None, max_rate: float | None = None, splitter: AbstractSplitterCommon | None = None, neurons_per_core: int | Tuple[int, ...] | None = None, n_colour_bits: int | None = None) SpikeSourcePoissonVertex[source]

Create a vertex for a population of the model.

Parameters:
  • n_neurons – The number of neurons in the population

  • label – The label to give to the vertex

  • label – The name for the vertex.

  • seed

  • max_rate

  • splitter – The splitter object needed for this vertex. Leave as None to delegate the choice of splitter to the selector.

Returns:

An application vertex for the population

default_population_parameters: Dict[str, Any] = {'max_rate': None, 'n_colour_bits': None, 'neurons_per_core': None, 'seed': None, 'splitter': None}

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.

class spynnaker.pyNN.models.spike_source.SpikeSourcePoissonMachineVertex(sdram: AbstractSDRAM, is_recording: bool, label: str | None, app_vertex: SpikeSourcePoissonVertex, vertex_slice: Slice)

Bases: MachineVertex, AbstractReceiveBuffersToHost, ProvidesProvenanceDataFromMachineImpl, AbstractHasProfileData, AbstractHasAssociatedBinary, AbstractRewritesDataSpecification, AbstractGeneratesDataSpecification, SendsSynapticInputsOverSDRAM

Vertex that implements a Poisson-distributed spike source.

Parameters:
  • sdram – SDRAM usage of this vertex

  • is_recording – Flag to say spikes are to be recorded

  • label – The optional name of the vertex

  • app_vertex – The application vertex that caused this machine vertex to be created. If None, there is no such application vertex.

  • vertex_slice – The slice of the application vertex that this machine vertex implements.

FAST_RATE_PER_TICK_CUTOFF = 10
PROFILE_TAG_LABELS = {0: 'TIMER', 1: 'PROB_FUNC'}
SEED_OFFSET_BYTES = 44
SEED_SIZE_BYTES = 16
SLOW_RATE_PER_TICK_CUTOFF = 0.01
generate_data_specification(spec: DataSpecificationGenerator, placement: Placement) None[source]

Generate a data specification.

Parameters:
  • spec – The data specification to write to

  • placement – The placement the vertex is located at

get_binary_file_name() str[source]
Returns:

The binary name to be run for this vertex.

get_binary_start_type() ExecutableType[source]
Returns:

The start type of the binary to be run.

get_n_keys_for_partition(partition_id: str) int[source]

Get the number of keys required by the given partition of edges.

Parameters:

partition_id – The identifier of the partition; the partition_id param is only used by some MachineVertex subclasses

Returns:

The number of keys required

get_profile_data(placement: Placement) ProfileData[source]

Get the profile data recorded during simulation.

Parameters:

placement

Returns:

profile data read from the Machine

get_recorded_region_ids() List[int][source]

Get the recording region IDs that have been recorded using buffering.

Returns:

The region numbers that have active recording

get_recording_region_base_address(placement: Placement) int[source]

Get the recording region base address.

Parameters:

placement – the placement object of the core to find the address of

Returns:

the base address of the recording region

max_spikes_per_second() float[source]
Returns:

The maximum expected number of spikes per second.

max_spikes_per_ts() float[source]
Returns:

The maximum expected number of spikes per timestep.

parse_extra_provenance_items(label: str, x: int, y: int, p: int, provenance_data: Sequence[int]) None[source]

Convert the remaining provenance words (those not in the standard set) into provenance items.

Called by get_provenance_data_from_machine()

Parameters:
  • label – A descriptive label for the vertex (derived from label and placed position) to be used for provenance error reporting to the user.

  • x – x coordinate of the chip where this core

  • y – y coordinate of the core where this core

  • p – virtual id of the core

  • provenance_data – The list of words of raw provenance data.

read_connections(synapse_info: SynapseInformation) ConnectionsArray[source]

Read the connections from the machine.

Parameters:

synapse_info – The synapse information being read

Returns:

The connections read back

read_parameters_from_machine(placement: Placement) None[source]

Reads the poisson rates of the machine if they could have changed.

Parameters:

placement

regenerate_data_specification(spec: DataSpecificationReloader, placement: Placement) None[source]

Regenerate the data specification, only generating regions that have changed and need to be reloaded.

Parameters:
  • spec – Where to write the regenerated spec

  • placement – Where are we regenerating for?

reload_required() bool[source]
Returns:

True if any data region needs to be reloaded.

property sdram_required: AbstractSDRAM

The SDRAM space required by the vertex.

sdram_requirement(sdram_machine_edge: SDRAMMachineEdge) int[source]

Asks a machine vertex for the SDRAM requirement it needs.

Parameters:

sdram_machine_edge – The SDRAM edge in question ~pacman.model.graphs.machine.SDRAMMachineEdge

Returns:

The size in bytes this vertex needs for the SDRAM edge.

set_rate_changed() None[source]

Records that the rates have changed.

set_reload_required(new_value: bool) None[source]

Indicate that the regions have been reloaded.

Parameters:

new_value – the new value

set_sdram_partition(sdram_partition: SourceSegmentedSDRAMMachinePartition) None[source]

Set the SDRAM partition. Must only be called once per instance.

Parameters:

sdram_partition – The SDRAM partition to receive synapses from

class spynnaker.pyNN.models.spike_source.SpikeSourcePoissonVariable(*args: Any, **kwargs: Any)

Bases: AbstractPyNNModel

Model to create a Spike Source Poisson Vertex.

=
param rates:

The spike rate of each neuron

param starts:

The start time of spikes on each neuron

param durations:

The duration of spikes on each neuron

absolute_max_atoms_per_core = 500
create_vertex(n_neurons: int, label: str, *, seed: int | None = None, splitter: AbstractSplitterCommon | None = None) SpikeSourcePoissonVertex[source]

Create a vertex for a population of the model.

Parameters:
  • n_neurons – The number of neurons in the population

  • label – The label to give to the vertex

  • seed

  • splitter

Returns:

An application vertex for the population

default_population_parameters: Dict[str, Any] = {'seed': None, 'splitter': None}

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.

class spynnaker.pyNN.models.spike_source.SpikeSourcePoissonVertex(n_neurons: int, label: str, seed: int | None, max_atoms_per_core: int | Tuple[int, ...] | None, model: SpikeSourcePoisson | SpikeSourcePoissonVariable, rate: float | Sequence[float] | None = None, start: int | Sequence[int] | None = None, duration: int | Sequence[int] | None = None, rates: Sequence[float] | NDArray[numpy.floating] | None = None, starts: Sequence[int] | NDArray[numpy.integer] | None = None, durations: Sequence[int] | NDArray[numpy.integer] | None = None, max_rate: float | None = None, splitter: AbstractSplitterCommon | None = None, n_colour_bits: int | None = None)

Bases: PopulationApplicationVertex, LegacyPartitionerAPI, SupportsStructure

A SpiNNaker vertex that is a Poisson-distributed Spike source.

Parameters:
  • n_neurons – The number of neurons in this vertex.

  • label – The optional name of the vertex.

  • max_atoms_per_core – The max number of atoms that can be placed on a core for each dimension, used in partitioning. If the vertex is n-dimensional, with n > 1, the value must be a tuple with a value for each dimension. If it is single-dimensional the value can be a 1-tuple or an int.

  • model – The model to get the parameters from

  • rate – The spike rate of all neuron

  • start – The start time of spikes on all neurons

  • duration – The duration of spikes on all neurons

  • rates – The spike rate of each neuron

  • starts – The start time of spikes on each neuron

  • durations – The duration of spikes on each neuron

  • max_rate – The maximum number of spikes for any neuron at any timestamp

  • splitter – The splitter object needed for this vertex. Leave as None to delegate the choice of splitter to the selector.

  • n_colour_bits

SPIKE_RECORDING_REGION_ID = 0
add_outgoing_projection(projection: Projection) None[source]

Add an outgoing projection from this vertex.

Parameters:

projection – The projection to add

property atoms_shape: Tuple[int, ...]

The “shape” of the atoms in the vertex i.e. how the atoms are split between the dimensions of the vertex. By default everything is 1-dimensional, so the value will be a 1-tuple but can be overridden by a vertex that supports multiple dimensions.

clear_spike_recording() None[source]

Clears the spike data from the buffer manager for this vertex.

create_machine_vertex(vertex_slice: Slice, sdram: AbstractSDRAM, label: str | None = None) SpikeSourcePoissonMachineVertex[source]

Create a machine vertex from this application vertex.

Parameters:
  • vertex_slice – The slice of atoms that the machine vertex will cover.

  • sdram – The SDRAM used by the machine vertex.

  • label – human readable label for the machine vertex

Returns:

The created machine vertex

property data: RangeDictionary[ndarray[tuple[Any, ...], dtype[floating]] | ndarray[tuple[Any, ...], dtype[integer]]]

A dictionary holding all the data as ranges

describe() Dict[str, str | ParameterHolder | Dict[str, Any]][source]

Return a human-readable description of the cell or synapse type.

The output may be customised 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.

Returns:

human-readable description of the vertex

get_buffer_data_type(name: str) BufferDataType[source]

Get the type of data recorded by the buffer manager.

The buffer data type controls how data returned by the cores is handled in NeoBufferDatabase.

Parameters:

name – The name of the variable recorded

Raises:

KeyError – if the variable isn’t being recorded

Returns:

Data type in the Buffer Database

get_data_type(name: str) None[source]

Get the type data returned by a recording of the variable.

This is the type of data the C code is returning. For instance data such as spikes this will be None.

Parameters:

name – The name of the variable to get the type of

Returns:

The data type used by the C code

Raises:

KeyError – If the variable isn’t recordable

get_neurons_recording(name: str, vertex_slice: Slice) ndarray[tuple[Any, ...], dtype[_ScalarT]][source]

Gets the neurons being recorded on the core with this slice.

Typically vertex_slice.get_raster_ids(atoms_shape) but may be a sublist if doing selective recording.

Parameters:
  • name – The name of the variable to get the region of

  • vertex_slice

Returns:

A list of the global raster IDs of the atoms in recording named variable within this slice

get_parameter_values(names: Names, selector: Selector = None) ParameterHolder[source]
Parameters:
  • names – The name or names of the parameter to get

  • selector – a description of the subrange to accept, or None for all. See: selector_to_ids()

Returns:

The values of a parameter or parameters for the whole Population or a subset if the selector is used.

Raises:

KeyError – if the parameter is not something that can be read

get_parameters() List[str][source]
Returns:

The names of all the parameters that can be obtained

get_recordable_variables() List[str][source]

Get a list of the names of things that can be recorded.

This methods list the variable recorded via the Population.

Includes both neuron and synapse recordable things

Returns:

List of variable names

get_recording_region(name: str) int[source]
Parameters:

name – The name of the variable to get the region of

Returns:

The recording region for the named variable.

Raises:

KeyError – If the variable isn’t being recorded

get_recording_sdram_usage(vertex_slice: Slice) AbstractSDRAM[source]
Parameters:

vertex_slice – Slice to get cost for

Returns:

SDRAm cost for recording

get_recording_variables() List[str][source]
Returns:

A list of variables that are currently being recorded.

get_sampling_interval_ms(name: str) int[source]

Get the sampling interval of the recording for the given variable.

The values is in ms and unless selective recording is used will be SpynnakerDataView.get_simulation_time_step_us()

Parameters:

name – The name of the variable

Returns:

Sampling rate in milliseconds for this variable

Raises:

KeyError – If the variable isn’t being recorded

get_sdram_used_by_atoms(vertex_slice: Slice) AbstractSDRAM[source]
Parameters:

vertex_slice – the low value of atoms to calculate resources from

Returns:

The separate SDRAM requirements for a range of atoms.

get_units(name: str) str[source]

Get the units of the given parameter or state variable.

Parameters:

name – the name of the parameter to get the units of

Returns:

The unit or this variable. For example ‘mV’ or ‘uS’. Will be an empty string for things like spikes and probability

Raises:

KeyError – if the name isn’t recognised or the units cannot be identified

property incoming_control_edge: ApplicationEdge | None

The live poisson control edge/ generator is set

kiss_seed(vertex_slice: Slice) Tuple[int, ...][source]

The seed for this vertex slice.

Generates and checks that the seed values generated by the given random number generator or seed to a random number generator are suitable for use as a mars 64 kiss seed.

Parameters:

vertex_slice

Returns:

a list of 4 integers which are used by the mars64 kiss random number generator for seeds.

property max_n_rates: int

the long length of any rates list.

property max_rate: float

The highest rate or 0 if no rate set.

max_spikes_per_ts() float[source]

Compute the maximum spike rate.

Returns:

The maximum number of spikes per simulation timestep.

property n_atoms: int

The number of atoms in the vertex.

property n_colour_bits: int

The number of colour bits sent by this vertex.

Assumed 0 unless overridden

property n_profile_samples: int

The n_profile_samples read from the config

property outgoing_projections: Sequence[Projection]

The projections outgoing from this vertex.

property rates: RangedList[ndarray[tuple[Any, ...], dtype[floating]]]

Get the rates.

read_connections(synapse_info: SynapseInformation) List[ConnectionsArray][source]

Read Poisson connections from the machine

Parameters:

synapse_info – The synapse information of the data being read

Returns:

The set of connections from all machine vertices

property seed: int | None

The seed set if any.

set_live_poisson_control_edge(edge: ApplicationEdge) None[source]

Sets the poisson generator.

Parameters:

edge

Raises:

ValueError – if already set

set_not_recording(name: str, indices: Collection[int] | None = None) None[source]

Set a variable not recording.

Parameters:
  • name – The name of the variable to not record

  • indices – The list of neuron indices to not record or None for all

Raises:

KeyError – if the variable cannot be stopped from recording

set_parameter_values(name: str, value: Values, selector: Selector = None) None[source]

Set the values of a parameter for the whole Population or a subset if the selector is used.

Parameters:
  • name – The name of the parameter to set

  • value – The new value

  • selector – a description of the subrange to accept, or None for all. See: selector_to_ids()

Raises:

KeyError – if the parameter is not something that can be changed

set_recording(name: str, sampling_interval: float | None = None, indices: Collection[int] | None = None) None[source]

Set a variable recording.

Parameters:
  • name – The name of the variable to set the status of

  • sampling_interval – How often the variable should be recorded or None for every time step, in milliseconds

  • indices – The list of neuron indices to record or None for all

Raises:

KeyError – if the variable cannot be recorded

set_structure(structure: BaseStructure) None[source]

Set the structure of the object.

Parameters:

structure – The structure to set

property time_to_spike: RangedList

The “time_to_spike range list.

update_kiss_seed(vertex_slice: Slice, seed: Sequence[int]) None[source]

Updates a KISS seed from the machine.

Parameters:
  • vertex_slice – the vertex slice to update seed of

  • seed – the seed