spynnaker.pyNN.utilities package¶
Subpackages¶
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
(incoming_projections)[source]¶ estimates the SDRAM for the bit field region
Parameters: incoming_projections (iterable(Projection)) – The projections that target the vertex in question 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
(incoming_projections)[source]¶ gets an estimate of the bitfield builder region
Parameters: incoming_projections (iterable(Projection)) – The projections that target the vertex in question Returns: SDRAM needed Return type: int
-
spynnaker.pyNN.utilities.bit_field_utilities.
reserve_bit_field_regions
(spec, incoming_projections, bit_field_builder_region, bit_filter_region, bit_field_key_region, bit_field_builder_region_ref=None, bit_filter_region_ref=None, bit_field_key_region_ref=None)[source]¶ reserves the regions for the bitfields
Parameters: - spec (DataSpecificationGenerator) – dsg spec writer
- incoming_projections (list(Projection)) – The projections to generate bitfields for
- bit_field_builder_region (int) – region id for the builder region
- bit_filter_region (int) – region id for the bitfield region
- bit_field_key_region (int) – region id for the key map
- bit_field_builder_region_ref (int or None) – Reference to give the region, or None if not referencable
- bit_filter_region_ref (int or None) – Reference to give the region, or None if not referencable
- bit_field_key_region_ref (int or None) – Reference to give the region, or None if not referencable
-
spynnaker.pyNN.utilities.bit_field_utilities.
write_bitfield_init_data
(spec, incoming_projections, vertex_slice, routing_info, 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
- incoming_projections (list(Projection)) – The projections to generate bitfields for
- vertex_slice (slice) – The slice of the target vertex
- routing_info (RoutingInfo) – 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
-
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.
SYNAPSE_SDRAM_PARTITION_ID
= 'SDRAM Synaptic Inputs'¶ The name of the partition for Synaptic SDRAM
-
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.constants.
WRITE_BANDWIDTH_BYTES_PER_SECOND
= 262144000¶ The conservative amount of write bandwidth available on a chip
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: -
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
¶
-
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:
-
set
(projection, attribute, data)[source]¶ Allow the addition of data from a projection and attribute.
Parameters: - projection (Projection) – the projection data was extracted from
- attribute (list(int) or tuple(int) or None) – the attribute to store
- data (ConnectionHolder) – attribute data in a connection holder
Return type:
-
spynnaker.pyNN.utilities.fake_HBP_Portal_machine_provider module¶
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
-
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: 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
-
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:
-
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)[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 (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:
-
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_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_time_to_write_us
(n_bytes, n_cores)[source]¶ Determine how long a write of a given number of bytes will take in us
Parameters:
-
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: 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:
-
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:
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.