def _write_synapse_parameters(self, spec, machine_vertex, machine_graph, graph_mapper, post_slices, post_slice_index, post_vertex_slice, input_type, machine_time_step): # Get the ring buffer shifts and scaling factors weight_scale = input_type.get_global_weight_scale() ring_buffer_shifts = self._get_ring_buffer_to_input_left_shifts( machine_vertex, machine_graph, graph_mapper, post_slices, post_slice_index, post_vertex_slice, machine_time_step, weight_scale) spec.switch_write_focus( region=constants.POPULATION_BASED_REGIONS.SYNAPSE_PARAMS.value) utility_calls.write_parameters_per_neuron( spec, post_vertex_slice, self._synapse_type.get_synapse_type_parameters()) spec.write_array(ring_buffer_shifts) weight_scales = numpy.array([ self._get_weight_scale(r) * weight_scale for r in ring_buffer_shifts ]) return weight_scales
def regenerate_data_specification(self, spec, placement, machine_time_step, time_scale_factor, vertex_slice): spec.reserve_memory_region( region=POPULATION_BASED_REGIONS.SYNAPSE_PARAMS.value, size=self._get_synapse_params_size(vertex_slice), label='SynapseParams') spec.switch_write_focus(POPULATION_BASED_REGIONS.SYNAPSE_PARAMS.value) write_parameters_per_neuron( spec, vertex_slice, self._synapse_type.get_synapse_type_parameters())
def _write_synapse_parameters( self, spec, subvertex, subgraph, graph_mapper, post_slices, post_slice_index, post_vertex_slice, input_type): # Get the ring buffer shifts and scaling factors weight_scale = input_type.get_global_weight_scale() ring_buffer_shifts = self._get_ring_buffer_to_input_left_shifts( subvertex, subgraph, graph_mapper, post_slices, post_slice_index, post_vertex_slice, self._machine_time_step, weight_scale) spec.switch_write_focus( region=constants.POPULATION_BASED_REGIONS.SYNAPSE_PARAMS.value) utility_calls.write_parameters_per_neuron( spec, post_vertex_slice, self._synapse_type.get_synapse_type_parameters()) spec.write_array(ring_buffer_shifts) weight_scales = numpy.array([ self._get_weight_scale(r) * weight_scale for r in ring_buffer_shifts]) return weight_scales
def _write_neuron_parameters(self, spec, key, vertex_slice): n_atoms = (vertex_slice.hi_atom - vertex_slice.lo_atom) + 1 spec.comment( "\nWriting Neuron Parameters for {} Neurons:\n".format(n_atoms)) # Set the focus to the memory region 2 (neuron parameters): spec.switch_write_focus( region=constants.POPULATION_BASED_REGIONS.NEURON_PARAMS.value) # Write whether the key is to be used, and then the key, or 0 if it # isn't to be used if key is None: spec.write_value(data=0) spec.write_value(data=0) else: spec.write_value(data=1) spec.write_value(data=key) # Write the number of neurons in the block: spec.write_value(data=n_atoms) # Write the size of the incoming spike buffer spec.write_value(data=self._incoming_spike_buffer_size) # Write the global parameters global_params = self._neuron_model.get_global_parameters() for param in global_params: spec.write_value(data=param.get_value(), data_type=param.get_dataspec_datatype()) # Write the neuron parameters utility_calls.write_parameters_per_neuron( spec, vertex_slice, self._neuron_model.get_neural_parameters()) # Write the input type parameters utility_calls.write_parameters_per_neuron( spec, vertex_slice, self._input_type.get_input_type_parameters()) # Write the additional input parameters if self._additional_input is not None: utility_calls.write_parameters_per_neuron( spec, vertex_slice, self._additional_input.get_parameters()) # Write the threshold type parameters utility_calls.write_parameters_per_neuron( spec, vertex_slice, self._threshold_type.get_threshold_parameters())
def _write_synapse_parameters( self, spec, subvertex, subgraph, graph_mapper, vertex_slice): # Get the ring buffer shifts and scaling factors ring_buffer_shifts = self._get_ring_buffer_to_input_left_shifts( subvertex, subgraph, graph_mapper, self._machine_time_step) weight_scales = [self._get_weight_scale(r) for r in ring_buffer_shifts] # update projections for future use in_partitioned_edges = subgraph.incoming_subedges_from_subvertex( subvertex) for partitioned_edge in in_partitioned_edges: partitioned_edge.weight_scales_setter(weight_scales) spec.switch_write_focus( region=constants.POPULATION_BASED_REGIONS.SYNAPSE_PARAMS.value) utility_calls.write_parameters_per_neuron( spec, vertex_slice, self._synapse_type.get_synapse_type_parameters()) spec.write_array(ring_buffer_shifts) return weight_scales
def _write_neuron_parameters( self, spec, key, vertex_slice): n_atoms = (vertex_slice.hi_atom - vertex_slice.lo_atom) + 1 spec.comment("\nWriting Neuron Parameters for {} Neurons:\n".format( n_atoms)) # Set the focus to the memory region 2 (neuron parameters): spec.switch_write_focus( region=constants.POPULATION_BASED_REGIONS.NEURON_PARAMS.value) # Write whether the key is to be used, and then the key, or 0 if it # isn't to be used if key is None: spec.write_value(data=0) spec.write_value(data=0) else: spec.write_value(data=1) spec.write_value(data=key) # Write the number of neurons in the block: spec.write_value(data=n_atoms) # Write the global parameters global_params = self._neuron_model.get_global_parameters() for param in global_params: spec.write_value(data=param.get_value(), data_type=param.get_dataspec_datatype()) # Write the neuron parameters utility_calls.write_parameters_per_neuron( spec, vertex_slice, self._neuron_model.get_neural_parameters()) # Write the input type parameters utility_calls.write_parameters_per_neuron( spec, vertex_slice, self._input_type.get_input_type_parameters()) # Write the additional input parameters if self._additional_input is not None: utility_calls.write_parameters_per_neuron( spec, vertex_slice, self._additional_input.get_parameters()) # Write the threshold type parameters utility_calls.write_parameters_per_neuron( spec, vertex_slice, self._threshold_type.get_threshold_parameters())
def _write_neuron_parameters(self, spec, key, vertex_slice, machine_time_step, time_scale_factor): # pylint: disable=too-many-arguments n_atoms = (vertex_slice.hi_atom - vertex_slice.lo_atom) + 1 spec.comment( "\nWriting Neuron Parameters for {} Neurons:\n".format(n_atoms)) # Set the focus to the memory region 2 (neuron parameters): spec.switch_write_focus( region=constants.POPULATION_BASED_REGIONS.NEURON_PARAMS.value) # Write the random back off value spec.write_value( random.randint(0, AbstractPopulationVertex._n_vertices)) # Write the number of microseconds between sending spikes time_between_spikes = ((machine_time_step * time_scale_factor) / (n_atoms * 2.0)) spec.write_value(data=int(time_between_spikes)) # Write whether the key is to be used, and then the key, or 0 if it # isn't to be used if key is None: spec.write_value(data=0) spec.write_value(data=0) else: spec.write_value(data=1) spec.write_value(data=key) # Write the number of neurons in the block: spec.write_value(data=n_atoms) # Write the size of the incoming spike buffer spec.write_value(data=self._incoming_spike_buffer_size) # Write the recording rates and sizes record_globals = self._neuron_recorder.get_global_parameters( vertex_slice) for param in record_globals: spec.write_value(data=param.get_value(), data_type=param.get_dataspec_datatype()) # Write the index parameters indexes = self._neuron_recorder.get_index_parameters(vertex_slice) utility_calls.write_parameters_per_neuron(spec, vertex_slice, indexes, slice_paramaters=True) # Write the global parameters global_params = self._neuron_model.get_global_parameters() for param in global_params: spec.write_value(data=param.get_value(), data_type=param.get_dataspec_datatype()) # Write the neuron parameters utility_calls.write_parameters_per_neuron( spec, vertex_slice, self._neuron_model.get_neural_parameters()) # Write the input type parameters utility_calls.write_parameters_per_neuron( spec, vertex_slice, self._input_type.get_input_type_parameters()) # Write the additional input parameters if self._additional_input is not None: utility_calls.write_parameters_per_neuron( spec, vertex_slice, self._additional_input.get_parameters()) # Write the threshold type parameters utility_calls.write_parameters_per_neuron( spec, vertex_slice, self._threshold_type.get_threshold_parameters())