spynnaker.pyNN.models.common package

Submodules

spynnaker.pyNN.models.common.recording_utils module

spynnaker.pyNN.models.common.recording_utils.get_buffer_sizes(buffer_max, space_needed, enable_buffered_recording)[source]
Parameters:
  • buffer_max (int) –
  • space_needed (int) –
  • enable_buffered_recording (bool) –
Return type:

int

spynnaker.pyNN.models.common.recording_utils.get_data(transceiver, placement, region, region_size)[source]

Get the recorded data from a region.

Parameters:
Return type:

tuple(bytearray, int)

spynnaker.pyNN.models.common.recording_utils.get_recording_region_size_in_bytes(n_machine_time_steps, bytes_per_timestep)[source]

Get the size of a recording region in bytes.

Parameters:
  • n_machine_time_steps (int) –
  • bytes_per_timestep (int) –
Return type:

int

spynnaker.pyNN.models.common.recording_utils.make_missing_string(missing)[source]
Parameters:missing (iterable(Placement)) –
Return type:str
spynnaker.pyNN.models.common.recording_utils.needs_buffering(buffer_max, space_needed, enable_buffered_recording)[source]
Parameters:
  • buffer_max (int) –
  • space_needed (int) –
  • enable_buffered_recording (bool) –
Return type:

bool

spynnaker.pyNN.models.common.recording_utils.pull_off_cached_lists(no_loads, cache_file)[source]

Extracts numpy based data from a file

Parameters:
  • no_loads (int) – the number of numpy elements in the file
  • cache_file (FileIO) – the file to extract from
Returns:

The extracted data

Return type:

ndarray

Module contents

class spynnaker.pyNN.models.common.AbstractEventRecordable[source]

Bases: object

Indicates that events can be recorded from this object.

clear_event_recording(buffer_manager, placements)[source]

Clear the recorded data from the object

Parameters:
Return type:

None

get_events(variable, placements, buffer_manager)[source]

Get the recorded events from the object

Parameters:
  • variable (str) – The variable to get the event data for
  • placements (Placements) – the placements object
  • buffer_manager (BufferManager) – the buffer manager object
Returns:

A numpy array of 2-element arrays of (neuron_id, time) ordered by time, one element per event

Return type:

ndarray(tuple(int,int))

get_events_sampling_interval(variable)[source]

Return the current sampling interval for events

Parameters:variable (str) – The variable to get the sampling interval for
Returns:Sampling interval in microseconds
Return type:float
is_recording_events(variable)[source]

Determine if events are being recorded

Parameters:variable (str) – The variable to check
Returns:True if events are recorded for the variable, False otherwise
Return type:bool
set_recording_events(variable, new_state=True, sampling_interval=None, indexes=None)[source]

Set events to being recorded. If new_state is false all other parameters are ignored.

Parameters:
  • variable (str) – The variable to set recording
  • new_state (bool) – Set if the events are recording or not
  • sampling_interval (int or None) – The interval at which events are recorded. Must be a whole multiple of the timestep. None will be taken as the timestep.
  • indexes (list(int) or None) – The indexes of the neurons that will record events. If None the assumption is all neurons are recording
class spynnaker.pyNN.models.common.AbstractNeuronRecordable[source]

Bases: object

Indicates that a variable (e.g., membrane voltage) can be recorded from this object.

clear_recording(variable, buffer_manager, placements)[source]

Clear the recorded data from the object

Parameters:
  • variable (str) – PyNN name of the variable
  • buffer_manager (BufferManager) – the buffer manager object
  • placements (Placements) – the placements object
Return type:

None

get_data(variable, n_machine_time_steps, placements, buffer_manager)[source]

Get the recorded data

Parameters:
Returns:

(data, recording_indices, sampling_interval)

Return type:

tuple(ndarray,list(int),float)

get_expected_n_rows(n_machine_time_steps, sampling_rate, vertex, variable)[source]

Returns the number of expected rows for a given runtime

Parameters:
  • n_machine_time_steps (int) – map of vertex to steps.
  • sampling_rate (int) – the sampling rate for this vertex
  • vertex (MachineVertex) – the machine vertex
  • variable (str) – the variable being recorded
Returns:

int the number of rows expected.

get_neuron_sampling_interval(variable)[source]

Returns the current sampling interval for this variable

Parameters:variable (str) – PyNN name of the variable
Returns:Sampling interval in microseconds
Return type:float
get_recordable_variables()[source]

Returns a list of the PyNN names of variables this model is expected to collect

Return type:list(str)
is_recording(variable)[source]

Determines if variable is being recorded.

Parameters:variable (str) – PyNN name of the variable
Returns:True if variable are being recorded, False otherwise
Return type:bool
set_recording(variable, new_state=True, sampling_interval=None, indexes=None)[source]

Sets variable to being recorded

Parameters:
  • variable (str) – PyNN name of the variable
  • new_state (bool) –
  • sampling_interval (int or None) –
  • indexes (list or None) – Which indices are to be recorded (or None for all)
class spynnaker.pyNN.models.common.AbstractSpikeRecordable[source]

Bases: object

Indicates that spikes can be recorded from this object.

clear_spike_recording(buffer_manager, placements)[source]

Clear the recorded data from the object

Parameters:
Return type:

None

get_spikes(placements, buffer_manager)[source]

Get the recorded spikes from the object

Parameters:
Returns:

A numpy array of 2-element arrays of (neuron_id, time) ordered by time, one element per event

Return type:

ndarray(tuple(int,int))

get_spikes_sampling_interval()[source]

Return the current sampling interval for spikes

Returns:Sampling interval in microseconds
Return type:float
is_recording_spikes()[source]

Determine if spikes are being recorded

Returns:True if spikes are being recorded, False otherwise
Return type:bool
set_recording_spikes(new_state=True, sampling_interval=None, indexes=None)[source]

Set spikes to being recorded. If new_state is false all other parameters are ignored.

Parameters:
  • new_state (bool) – Set if the spikes are recording or not
  • sampling_interval (int or None) – The interval at which spikes are recorded. Must be a whole multiple of the timestep. None will be taken as the timestep.
  • indexes (list(int) or None) – The indexes of the neurons that will record spikes. If None the assumption is all neurons are recording
class spynnaker.pyNN.models.common.EIEIOSpikeRecorder[source]

Bases: object

Records spikes using EIEIO format

get_dtcm_usage_in_bytes()[source]
Return type:int
get_n_cpu_cycles(n_neurons)[source]
Return type:int
get_spikes(label, buffer_manager, region, placements, application_vertex, base_key_function)[source]

Get the recorded spikes from the object

Parameters:
Returns:

A numpy array of 2-element arrays of (neuron_id, time) ordered by time, one element per event

Return type:

ndarray(tuple(int,int))

record
Return type:bool
set_recording(new_state, sampling_interval=None)[source]
Parameters:
  • new_state – bool
  • sampling_interval – not supported functionality
class spynnaker.pyNN.models.common.NeuronRecorder(allowed_variables, data_types, bitfield_variables, n_neurons, per_timestep_variables, per_timestep_datatypes, events_per_core_variables, events_per_core_datatypes)[source]

Bases: object

Parameters:
MAX_REWIRES = 'max_rewires'

max_rewires

PACKETS = 'packets-per-timestep'

packets-per-timestep

PACKETS_TYPE = 2

packets-per-timestep data type

REWIRING = 'rewiring'

rewiring

REWIRING_TYPE = 2

rewiring data type

SPIKES = 'spikes'

flag for spikes

check_indexes(indexes)[source]
Parameters:indexes (list(int)) –
static expected_rows_for_a_run_time(n_machine_time_steps, sampling_rate)[source]

determines how many rows to see based off how long its ran for

Parameters:
  • n_machine_time_steps (int) – map of vertex to time steps
  • sampling_rate (float) – the sampling rate for a given variable
Returns:

how many rows there should be.

Return type:

int

get_buffered_sdram(variable, vertex_slice, n_machine_time_steps)[source]

Returns the SDRAM used for this may time steps

If required the total is rounded up so the space will always fit

Parameters:
  • variable (str) – The PyNN variable name to get buffered sdram of
  • vertex_slice (Slice) –
  • n_machine_time_steps (int) – how many machine time steps to run for
Returns:

data size

Return type:

int

get_buffered_sdram_per_record(variable, vertex_slice)[source]

Return the SDRAM used per record

Parameters:
  • variable (str) – PyNN variable name
  • vertex_slice (Slice) –
Returns:

Return type:

int

get_buffered_sdram_per_timestep(variable, vertex_slice)[source]

Return the SDRAM used per timestep.

In the case where sampling is used it returns the average for recording and none recording based on the recording rate

Parameters:
  • variable (str) – PyNN variable name
  • vertex_slice (Slice) –
Returns:

Return type:

int

get_dtcm_usage_in_bytes(vertex_slice)[source]
Parameters:vertex_slice (Slice) –
Return type:int
get_event_recordable_variables()[source]
Return type:iterable(str)
get_events(label, buffer_manager, placements, application_vertex, variable)[source]

Read events mapped to time and neuron IDs from the SpiNNaker machine.

Parameters:
Returns:

Return type:

ndarray(tuple(int,int,int,int))

get_exact_static_sdram_usage(vertex_slice)[source]

gets the exact sdram needed by the dsg region. :param ~pacman.model.graphs.common.Slice vertex_slice: :rtype: int

NOTE: does not take into account the struct that’s being allocated by the c code

get_matrix_data(label, buffer_manager, placements, application_vertex, variable, n_machine_time_steps)[source]

Read a data mapped to time and neuron IDs from the SpiNNaker machine and converts to required data types with scaling if needed.

Parameters:
  • label (str) – vertex label
  • buffer_manager (BufferManager) – the manager for buffered data
  • placements (Placements) – the placements object
  • application_vertex (ApplicationVertex) –
  • variable (str) – PyNN name for the variable (V, gsy_inh, etc.)
  • n_machine_time_steps (int) –
Returns:

(data, recording_indices, sampling_interval)

Return type:

tuple(ndarray, list(int), float)

get_n_cpu_cycles(n_neurons)[source]
Parameters:n_neurons (int) –
Return type:int
get_neuron_sampling_interval(variable)[source]

Return the current sampling interval for this variable

Parameters:variable (str) – PyNN name of the variable
Returns:Sampling interval in microseconds
Return type:float
get_recordable_variables()[source]
Return type:iterable(str)
get_sampling_overflow_sdram(vertex_slice)[source]

Get the extra SDRAM that should be reserved if using per_timestep

This is the extra that must be reserved if per_timestep is an average rather than fixed for every timestep.

When sampling the average * time_steps may not be quite enough. This returns the extra space in the worst case where time_steps is a multiple of sampling rate + 1, and recording is done in the first and last time_step

Parameters:vertex_slice (Slice) –
Returns:Highest possible overflow needed
Return type:int
get_sdram_usage_in_bytes(vertex_slice)[source]
Parameters:vertex_slice (Slice) –
Return type:int
get_spikes(label, buffer_manager, placements, application_vertex, variable)[source]

Read spikes mapped to time and neuron IDs from the SpiNNaker machine.

Parameters:
Returns:

Return type:

ndarray(tuple(int,int))

get_static_sdram_usage(vertex_slice)[source]
Parameters:vertex_slice (Slice) –
Return type:int
get_variable_sdram_usage(vertex_slice)[source]
Parameters:vertex_slice (Slice) –
Return type:VariableSDRAM
is_recording(variable)[source]
Parameters:variable (str) –
Return type:bool
recorded_ids_by_slice(vertex_slice)[source]
Parameters:vertex_slice (Slice) –
Return type:list(int)
recorded_region_ids
Return type:list(int)
recording_variables
Return type:list(str)
set_max_rewires_per_ts(max_rewires_per_ts)[source]
Parameters:max_rewires_per_ts (int) – the maximum rewires per timestep
set_recording(variable, new_state, sampling_interval=None, indexes=None)[source]
Parameters:
  • variable (str) – PyNN variable name
  • new_state (bool) –
  • sampling_interval (int) –
  • indexes (iterable(int)) –
write_neuron_recording_region(spec, neuron_recording_region, vertex_slice, data_n_time_steps)[source]

recording data specification

Parameters:
  • spec (DataSpecificationGenerator) – dsg spec
  • neuron_recording_region (int) – the recording region
  • vertex_slice (Slice) – the vertex slice
  • data_n_time_steps (int) – how many time steps to run this time
Return type:

None

class spynnaker.pyNN.models.common.MultiSpikeRecorder[source]

Bases: object

get_dtcm_usage_in_bytes()[source]
Return type:int
get_n_cpu_cycles(n_neurons)[source]
Parameters:n_neurons (int) –
Return type:int
get_sdram_usage_in_bytes(n_neurons, spikes_per_timestep)[source]
Return type:AbstractSDRAM
get_spikes(label, buffer_manager, region, placements, application_vertex)[source]
Parameters:
Returns:

A numpy array of 2-element arrays of (neuron_id, time) ordered by time, one element per event

Return type:

ndarray(tuple(int,int))

record
Return type:bool
class spynnaker.pyNN.models.common.SimplePopulationSettable[source]

Bases: spynnaker.pyNN.models.abstract_models.abstract_population_settable.AbstractPopulationSettable

An object all of whose properties can be accessed from a PyNN Population i.e. no properties are hidden

get_value(key)[source]

Get a property

Parameters:key (str) – the name of the property
Return type:Any or float or int or list(float) or list(int)
set_value(key, value)[source]

Set a property

Parameters:
  • key (str) – the name of the parameter to change
  • value (Any or float or int or list(float) or list(int)) – the new value of the parameter to assign
spynnaker.pyNN.models.common.get_buffer_sizes(buffer_max, space_needed, enable_buffered_recording)[source]
Parameters:
  • buffer_max (int) –
  • space_needed (int) –
  • enable_buffered_recording (bool) –
Return type:

int

spynnaker.pyNN.models.common.get_data(transceiver, placement, region, region_size)[source]

Get the recorded data from a region.

Parameters:
Return type:

tuple(bytearray, int)

spynnaker.pyNN.models.common.needs_buffering(buffer_max, space_needed, enable_buffered_recording)[source]
Parameters:
  • buffer_max (int) –
  • space_needed (int) –
  • enable_buffered_recording (bool) –
Return type:

bool

spynnaker.pyNN.models.common.get_recording_region_size_in_bytes(n_machine_time_steps, bytes_per_timestep)[source]

Get the size of a recording region in bytes.

Parameters:
  • n_machine_time_steps (int) –
  • bytes_per_timestep (int) –
Return type:

int

spynnaker.pyNN.models.common.pull_off_cached_lists(no_loads, cache_file)[source]

Extracts numpy based data from a file

Parameters:
  • no_loads (int) – the number of numpy elements in the file
  • cache_file (FileIO) – the file to extract from
Returns:

The extracted data

Return type:

ndarray