spynnaker.pyNN.utilities package

Submodules

spynnaker.pyNN.utilities.bit_field_utilities module

spynnaker.pyNN.utilities.bit_field_utilities.ELEMENTS_USED_IN_BIT_FIELD_HEADER = 2

n_filters, pointer for array

spynnaker.pyNN.utilities.bit_field_utilities.ELEMENTS_USED_IN_EACH_BIT_FIELD = 3

number of elements

spynnaker.pyNN.utilities.bit_field_utilities.N_ELEMENTS_IN_EACH_KEY_N_ATOM_MAP = 2

n elements in each key to n atoms map for bitfield (key, n atoms)

spynnaker.pyNN.utilities.bit_field_utilities.N_KEYS_DATA_SET_IN_WORDS = 1

n key to n neurons maps size in words

spynnaker.pyNN.utilities.bit_field_utilities.N_REGIONS_ADDRESSES = 6

the regions addresses needed ( pop table, synaptic matrix, direct matrix, bit_field, bit field builder, bit_field_key, structural region)

spynnaker.pyNN.utilities.bit_field_utilities.exact_sdram_for_bit_field_builder_region()[source]

Gets the SDRAM requirement for the builder region

Returns:the SDRAM requirement for the builder region
Return type:int
spynnaker.pyNN.utilities.bit_field_utilities.get_estimated_sdram_for_bit_field_region(app_graph, vertex)[source]

estimates the SDRAM for the bit field region

Parameters:
Returns:

the estimated number of bytes used by the bit field region

Return type:

int

spynnaker.pyNN.utilities.bit_field_utilities.get_estimated_sdram_for_key_region(app_graph, vertex)[source]

gets an estimate of the bitfield builder region

Parameters:
Returns:

SDRAM needed

Return type:

int

spynnaker.pyNN.utilities.bit_field_utilities.reserve_bit_field_regions(spec, machine_graph, n_key_map, vertex, bit_field_builder_region, bit_filter_region, bit_field_key_region)[source]

reserves the regions for the bitfields

Parameters:
spynnaker.pyNN.utilities.bit_field_utilities.write_bitfield_init_data(spec, machine_vertex, machine_graph, routing_info, n_key_map, bit_field_builder_region, master_pop_region_id, synaptic_matrix_region_id, direct_matrix_region_id, bit_field_region_id, bit_field_key_map_region_id, structural_dynamics_region_id, has_structural_dynamics_region)[source]

writes the init data needed for the bitfield generator

Parameters:
  • spec (DataSpecificationGenerator) – data spec writer
  • machine_vertex (MachineVertex) – machine vertex
  • machine_graph (MachineGraph) – machine graph
  • routing_info (RoutingInfo) – keys
  • n_key_map (AbstractMachinePartitionNKeysMap) – map for edge to n keys
  • bit_field_builder_region (int) – the region id for the bitfield builder
  • master_pop_region_id (int) – the region id for the master pop table
  • synaptic_matrix_region_id (int) – the region id for the synaptic matrix
  • direct_matrix_region_id (int) – the region id for the direct matrix
  • bit_field_region_id (int) – the region id for the bit-fields
  • bit_field_key_map_region_id (int) – the region id for the key map
  • structural_dynamics_region_id (int) – the region id for the structural
  • has_structural_dynamics_region (bool) – whether the core has a structural_dynamics region

spynnaker.pyNN.utilities.constants module

spynnaker.pyNN.utilities.constants.LIVE_POISSON_CONTROL_PARTITION_ID = 'CONTROL'

The partition ID used for Poisson live control data

spynnaker.pyNN.utilities.constants.MIN_SUPPORTED_DELAY = 1

the minimum supported delay slot between two neurons

spynnaker.pyNN.utilities.constants.OUT_SPIKE_BYTES = 32

The number of bytes for each spike line

spynnaker.pyNN.utilities.constants.OUT_SPIKE_SIZE = 8

The size of each output spike line

class spynnaker.pyNN.utilities.constants.POPULATION_BASED_REGIONS[source]

Bases: enum.Enum

Regions for populations.

BIT_FIELD_BUILDER = 13
BIT_FIELD_FILTER = 12
BIT_FIELD_KEY_MAP = 14
CONNECTOR_BUILDER = 10
DIRECT_MATRIX = 11
NEURON_PARAMS = 1
NEURON_RECORDING = 7
POPULATION_TABLE = 3
PROFILING = 9
PROVENANCE_DATA = 8
STRUCTURAL_DYNAMICS = 6
SYNAPSE_DYNAMICS = 5
SYNAPSE_PARAMS = 2
SYNAPTIC_MATRIX = 4
SYSTEM = 0
spynnaker.pyNN.utilities.constants.POP_TABLE_MAX_ROW_LENGTH = 256

The maximum row length of the master population table

spynnaker.pyNN.utilities.constants.SPIKE_PARTITION_ID = 'SPIKE'

The partition ID used for spike data

spynnaker.pyNN.utilities.constants.SYNAPTIC_ROW_HEADER_WORDS = 3

Words: 2 for row length and number of rows and 1 for plastic region size (which might be 0)

spynnaker.pyNN.utilities.data_cache module

class spynnaker.pyNN.utilities.data_cache.DataCache(label, description, segment_number, recording_start_time, t)[source]

Bases: object

Storage object to hold all the data to (re)create a Neo Segment

Note

Required because deep-copy does not work on neo Objects

Stores the Data shared by all variable types at the top level and holds a cache for the variable specific data.

Parameters:
  • label (str) – cache label
  • description (str or dict) – cache description
  • segment_number (int) – cache segment number
  • recording_start_time (float) – when this cache was started in recording space.
  • t (float) – time
description
get_data(variable)[source]

Get the variable cache for the named variable

Parameters:variable (str) – name of variable to get cache for
Returns:The cache data, IDs, indexes and units
Return type:VariableCache
has_data(variable)[source]

Checks if data for a variable has been cached

Parameters:variable (str) – Name of variable
Returns:True if there is cached data
Return type:bool
label
rec_datetime
recording_start_time
save_data(variable, data, indexes, n_neurons, units, sampling_interval)[source]

Saves the data for one variable in this segment

Parameters:
  • variable (str) – name of variable data applies to
  • data (ndarray) – raw data in sPyNNaker format
  • indexes (ndarray) – population indexes for which data should be returned
  • n_neurons (int) – Number of neurons in the population, regardless of if they where recording or not.
  • units (str) – the units in which the data is
  • sampling_interval (float or int) – The number of milliseconds between samples.
segment_number
t
variables

Provides a list of which variables data has been cached for

Return type:Iterator (str)

spynnaker.pyNN.utilities.extracted_data module

class spynnaker.pyNN.utilities.extracted_data.ExtractedData[source]

Bases: object

Data holder for all synaptic data being extracted in parallel.

get(projection, attribute)[source]

Allow getting data from a given projection and attribute

Parameters:
Returns:

the attribute data in a connection holder

Return type:

ConnectionHolder

set(projection, attribute, data)[source]

Allow the addition of data from a projection and attribute.

Parameters:
Return type:

None

spynnaker.pyNN.utilities.fake_HBP_Portal_machine_provider module

class spynnaker.pyNN.utilities.fake_HBP_Portal_machine_provider.FakeHBPPortalMachineProvider(n_boards, config)[source]

Bases: object

create()[source]
destroy()[source]
get_machine_info()[source]
wait_till_not_ready()[source]
wait_until_ready()[source]

spynnaker.pyNN.utilities.running_stats module

class spynnaker.pyNN.utilities.running_stats.RunningStats[source]

Bases: object

Keeps running statistics. From: http://www.johndcook.com/blog/skewness_kurtosis/

add_item(x)[source]

Adds an item to the running statistics.

Parameters:x (int or float) – The item to add
add_items(mean, variance, n_items)[source]

Add a bunch of items (via their statistics).

Parameters:
  • mean (float) – The mean of the items to add.
  • variance (float) – The variance of the items to add.
  • n_items (int) – The number of items represented.
mean

The mean of the items seen.

Return type:float
n_items

The number of items seen.

Return type:int
standard_deviation

The population standard deviation of the items seen.

Return type:float
variance

The variance of the items seen.

Return type:float

spynnaker.pyNN.utilities.struct module

class spynnaker.pyNN.utilities.struct.Struct(field_types)[source]

Bases: object

Represents a C code structure.

Parameters:field_types (list(DataType)) – The types of the fields, ordered as they appear in the struct.
field_types

The types of the fields, ordered as they appear in the struct.

Return type:list(DataType)
get_data(values, offset=0, array_size=1)[source]

Get a numpy array of uint32 of data for the given values

Parameters:
  • values (list(int or float or list(int) or list(float) or RangedList)) – A list of values with length the same size as the number of fields returned by field_types
  • offset (int) – The offset into each of the values where to start
  • array_size (int) – The number of structs to generate
Return type:

ndarray(dtype=”uint32”)

get_size_in_whole_words(array_size=1)[source]

Get the size of the struct in whole words in an array of given size (default 1 item)

Parameters:array_size (int) – The number of elements in an array of structs
Return type:int
numpy_dtype

The numpy data type of the struct

Return type:dtype
read_data(data, offset=0, array_size=1)[source]

Read a bytearray of data and convert to struct values

Parameters:
  • data (bytes or bytearray) – The data to be read
  • offset (int) – Index of the byte at the start of the valid data
  • array_size (int) – The number of struct elements to read
Returns:

a list of lists of data values, one list for each struct element

Return type:

list(float)

spynnaker.pyNN.utilities.utility_calls module

utility class containing simple helper methods

spynnaker.pyNN.utilities.utility_calls.check_directory_exists_and_create_if_not(filename)[source]

Create a parent directory for a file if it doesn’t exist

Parameters:filename (str) – The file whose parent directory is to be created
spynnaker.pyNN.utilities.utility_calls.convert_param_to_numpy(param, no_atoms)[source]

Convert parameters into numpy arrays.

Parameters:
Returns:

the converted param as an array of floats

Return type:

ndarray(float)

spynnaker.pyNN.utilities.utility_calls.convert_to(value, data_type)[source]

Convert a value to a given data type

Parameters:
  • value – The value to convert
  • data_type (DataType) – The data type to convert to
Returns:

The converted data as a numpy data type

Return type:

ndarray(int32)

spynnaker.pyNN.utilities.utility_calls.create_mars_kiss_seeds(rng, seed=None)[source]

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:
  • rng (None or RandomState) – the random number generator.
  • seed (int or None) – the seed to create a random number generator if not handed.
Returns:

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

Return type:

list(int)

spynnaker.pyNN.utilities.utility_calls.get_maximum_probable_value(dist, n_items, chance=0.01)[source]

Get the likely maximum value of a RandomDistribution given a number of draws

spynnaker.pyNN.utilities.utility_calls.get_mean(dist)[source]

Get the mean of a RandomDistribution

spynnaker.pyNN.utilities.utility_calls.get_minimum_probable_value(dist, n_items, chance=0.01)[source]

Get the likely minimum value of a RandomDistribution given a number of draws

spynnaker.pyNN.utilities.utility_calls.get_n_bits(n_values)[source]

Determine how many bits are required for the given number of values

Parameters:n_values (int) – the number of values (starting at 0)
Returns:the number of bits required to express that many values
Return type:int
spynnaker.pyNN.utilities.utility_calls.get_probability_within_range(dist, lower, upper)[source]

Get the probability that a value will fall within the given range for a given RandomDistribution

spynnaker.pyNN.utilities.utility_calls.get_probable_maximum_selected(n_total_trials, n_trials, selection_prob, chance=0.01)[source]

Get the likely maximum number of items that will be selected from a set of n_trials from a total set of n_total_trials with a probability of selection of selection_prob

spynnaker.pyNN.utilities.utility_calls.get_probable_minimum_selected(n_total_trials, n_trials, selection_prob, chance=0.01)[source]

Get the likely minimum number of items that will be selected from a set of n_trials from a total set of n_total_trials with a probability of selection of selection_prob

spynnaker.pyNN.utilities.utility_calls.get_standard_deviation(dist)[source]

Get the standard deviation of a RandomDistribution

spynnaker.pyNN.utilities.utility_calls.get_variance(dist)[source]

Get the variance of a RandomDistribution

spynnaker.pyNN.utilities.utility_calls.high(dist)[source]

Gets the high or max boundary value for this distribution

Could return None

spynnaker.pyNN.utilities.utility_calls.low(dist)[source]

Gets the high or min boundary value for this distribution

Could return None

spynnaker.pyNN.utilities.utility_calls.moved_in_v6(old_location, new_location)[source]

Warns the users that they are using an old import.

In version 7 this will ne upgraded to a exception and then later removed

Parameters:
  • old_location (str) – old import
  • new_location (str) – new import
Raise:

an exception if in CONTINUOUS_INTEGRATION

spynnaker.pyNN.utilities.utility_calls.read_in_data_from_file(file_path, min_atom, max_atom, min_time, max_time, extra=False)[source]
Read in a file of data values where the values are in a format of:
<time> <atom ID> <data value>
Parameters:
  • file_path (str) – absolute path to a file containing the data
  • min_atom (int) – min neuron ID to which neurons to read in
  • max_atom (int) – max neuron ID to which neurons to read in
  • extra
  • min_time (float or int) – min time slot to read neurons values of.
  • max_time (float or int) – max time slot to read neurons values of.
Returns:

a numpy array of (time stamp, atom ID, data value)

Return type:

ndarray(tuple(float, int, float))

spynnaker.pyNN.utilities.utility_calls.read_spikes_from_file(file_path, min_atom=0, max_atom=inf, min_time=0, max_time=inf, split_value='\t')[source]
Read spikes from a file formatted as:
<time> <neuron ID>
Parameters:
  • file_path (str) – absolute path to a file containing spike values
  • min_atom (int or float) – min neuron ID to which neurons to read in
  • max_atom (int or float) – max neuron ID to which neurons to read in
  • min_time (float or int) – min time slot to read neurons values of.
  • max_time (float or int) – max time slot to read neurons values of.
  • split_value (str) – the pattern to split by
Returns:

a numpy array with max_atom elements each of which is a list of spike times.

Return type:

numpy.ndarray(int, int)

spynnaker.pyNN.utilities.variable_cache module

class spynnaker.pyNN.utilities.variable_cache.VariableCache(data, indexes, n_neurons, units, sampling_interval)[source]

Bases: object

Simple holder method to keep data, IDs, indexes and units together

Typically used to recreate the Neo object for one type of variable for one segment.

Parameters:
  • data (ndarray) – raw data in sPyNNaker format
  • indexes (list(int)) – Population indexes for which data was collected
  • n_neurons (int) – Number of neurons in the population, regardless of whether they were recording or not.
  • units (str) – the units in which the data is
  • sampling_interval (float or int) – The number of milliseconds between samples.
data
Return type:ndarray
indexes
Return type:list(int)
n_neurons
Return type:int
sampling_interval
Return type:float or int
units
Return type:str

Module contents