def __init__(self, n_neurons, label, constraints, max_atoms_per_core, spikes_per_second, ring_buffer_sigma, incoming_spike_buffer_size, neuron_impl, pynn_model): # pylint: disable=too-many-arguments, too-many-locals super(AbstractPopulationVertex, self).__init__(label, constraints, max_atoms_per_core) self.__n_atoms = n_neurons self.__n_subvertices = 0 self.__n_data_specs = 0 # buffer data self.__incoming_spike_buffer_size = incoming_spike_buffer_size # get config from simulator config = globals_variables.get_simulator().config if incoming_spike_buffer_size is None: self.__incoming_spike_buffer_size = config.getint( "Simulation", "incoming_spike_buffer_size") self.__neuron_impl = neuron_impl self.__pynn_model = pynn_model self._parameters = SpynnakerRangeDictionary(n_neurons) self._state_variables = SpynnakerRangeDictionary(n_neurons) self.__neuron_impl.add_parameters(self._parameters) self.__neuron_impl.add_state_variables(self._state_variables) self.__initial_state_variables = None self.__updated_state_variables = set() # Set up for recording recordable_variables = list( self.__neuron_impl.get_recordable_variables()) record_data_types = dict( self.__neuron_impl.get_recordable_data_types()) self.__neuron_recorder = NeuronRecorder(recordable_variables, record_data_types, [NeuronRecorder.SPIKES], n_neurons) # Set up synapse handling self.__synapse_manager = SynapticManager( self.__neuron_impl.get_n_synapse_types(), ring_buffer_sigma, spikes_per_second, config) # bool for if state has changed. self.__change_requires_mapping = True self.__change_requires_neuron_parameters_reload = False self.__change_requires_data_generation = False self.__has_reset_last = True # Set up for profiling self.__n_profile_samples = helpful_functions.read_config_int( config, "Reports", "n_profile_samples")
def test_uniform(self): # Need to do setup to get a pynn version p.setup(10) rd = SpynnakerRangeDictionary(10) rd["a"] = RandomDistribution("uniform", parameters_pos=[-65.0, -55.0]) ranges = rd["a"].get_ranges() assert 10 == len(ranges)
def __init__(self, n_neurons, e_rev_E, e_rev_I): self._units = { E_REV_E: "mV", E_REV_I: "mV"} self._n_neurons = n_neurons self._data = SpynnakerRangeDictionary(size=n_neurons) self._data[E_REV_E] = e_rev_E self._data[E_REV_I] = e_rev_I
def __init__(self, n_neurons, du_th, tau_th, v_thresh): self._n_neurons = n_neurons self._data = SpynnakerRangeDictionary(size=n_neurons) self._data[DU_TH] = du_th self._data[DU_TH_INV] = self._data[DU_TH].apply_operation( lambda x: 1.0 / x) self._data[TAU_TH] = tau_th self._data[TAU_TH_INV] = self._data[TAU_TH].apply_operation( lambda x: 1.0 / x) self._data[V_THRESH] = v_thresh
def __copy_ranged_dict(source, merge=None, merge_keys=None): target = SpynnakerRangeDictionary(len(source)) for key in source.keys(): copy_list = SpynnakerRangedList(len(source)) if merge_keys is None or key not in merge_keys: init_list = source.get_list(key) else: init_list = merge.get_list(key) for start, stop, value in init_list.iter_ranges(): is_list = (hasattr(value, '__iter__') and not isinstance(value, str)) copy_list.set_value_by_slice(start, stop, value, is_list) target[key] = copy_list return target
def __init__(self, n_neurons, tau_syn_E, tau_syn_I, initial_input_exc=0.0, initial_input_inh=0.0): # pylint: disable=too-many-arguments self._units = { TAU_SYN_E: "mV", TAU_SYN_I: 'mV', GSYN_EXC: "uS", GSYN_INH: "uS"} self._n_neurons = n_neurons self._data = SpynnakerRangeDictionary(size=n_neurons) self._data[TAU_SYN_E] = tau_syn_E self._data[TAU_SYN_I] = tau_syn_I self._data[GSYN_EXC] = initial_input_exc self._data[GSYN_INH] = initial_input_inh
def __init__(self, n_neurons, exc_response, exc_exp_response, tau_syn_E, inh_response, inh_exp_response, tau_syn_I): # pylint: disable=too-many-arguments self._data = SpynnakerRangeDictionary(size=n_neurons) self._data[EXC_RESPONSE] = exc_response self._data[EXC_EXP_RESPONSE] = exc_exp_response self._data[TAU_SYN_E] = tau_syn_E self._data[INH_RESPONSE] = inh_response self._data[INH_EXP_RESPONSE] = inh_exp_response self._data[TAU_SYN_I] = tau_syn_I self._exc_response = convert_param_to_numpy(exc_response, n_neurons) self._exc_exp_response = convert_param_to_numpy( exc_exp_response, n_neurons) self._tau_syn_E = convert_param_to_numpy(tau_syn_E, n_neurons) self._inh_response = convert_param_to_numpy(inh_response, n_neurons) self._inh_exp_response = convert_param_to_numpy( inh_exp_response, n_neurons) self._tau_syn_I = convert_param_to_numpy(tau_syn_I, n_neurons)
def __init__(self, n_neurons, v_init, v_rest, tau_m, cm, i_offset): # pylint: disable=too-many-arguments self._units = { V_INIT: 'mV', V_REST: 'mV', TAU_M: 'ms', CM: 'nF', I_OFFSET: 'nA' } self._n_neurons = n_neurons if v_init is None: v_init = v_rest self._data = SpynnakerRangeDictionary(size=n_neurons) self._data[V_INIT] = v_init self._data[V_REST] = v_rest self._data[TAU_M] = tau_m self._data[CM] = cm self._data[I_OFFSET] = i_offset self._data["r_membrane"] = self._data[TAU_M] / self._data[CM]
def __init__(self, n_neurons, a, b, c, d, v_init, u_init, i_offset): # pylint: disable=too-many-arguments self._units = { A: "ms", B: "ms", C: "mV", D: "mV/ms", V_INIT: "mV", U_INIT: "mV/ms", I_OFFSET: "nA" } self._n_neurons = n_neurons self._data = SpynnakerRangeDictionary(size=n_neurons) self._data[A] = a self._data[B] = b self._data[C] = c self._data[D] = d self._data[V_INIT] = v_init self._data[U_INIT] = u_init self._data[I_OFFSET] = i_offset
def __init__(self, n_neurons, initial_input_exc, initial_input_inh): self._data = SpynnakerRangeDictionary(size=n_neurons) self._data[INITIAL_INPUT_EXC] = initial_input_exc self._data[INITIAL_INPUT_INH] = initial_input_inh
def __init__(self, n_neurons, label, constraints, max_atoms_per_core, spikes_per_second, ring_buffer_sigma, incoming_spike_buffer_size, neuron_impl, pynn_model): """ :param int n_neurons: The number of neurons in the population :param str label: The label on the population :param list(~pacman.model.constraints.AbstractConstraint) constraints: Constraints on where a population's vertices may be placed. :param int max_atoms_per_core: The maximum number of atoms (neurons) per SpiNNaker core. :param spikes_per_second: Expected spike rate :type spikes_per_second: float or None :param ring_buffer_sigma: How many SD above the mean to go for upper bound of ring buffer \ size; a good starting choice is 5.0. Given length of simulation \ we can set this for approximate number of saturation events. :type ring_buffer_sigma: float or None :param incoming_spike_buffer_size: :type incoming_spike_buffer_size: int or None :param AbstractNeuronImpl neuron_impl: The (Python side of the) implementation of the neurons themselves. :param AbstractPyNNNeuronModel pynn_model: The PyNN neuron model that this vertex is working on behalf of. """ # pylint: disable=too-many-arguments, too-many-locals ApplicationVertex.__init__(self, label, constraints, max_atoms_per_core) self.__n_atoms = n_neurons self.__n_subvertices = 0 self.__n_data_specs = 0 # buffer data self.__incoming_spike_buffer_size = incoming_spike_buffer_size # get config from simulator config = globals_variables.get_simulator().config if incoming_spike_buffer_size is None: self.__incoming_spike_buffer_size = config.getint( "Simulation", "incoming_spike_buffer_size") self.__neuron_impl = neuron_impl self.__pynn_model = pynn_model self._parameters = SpynnakerRangeDictionary(n_neurons) self._state_variables = SpynnakerRangeDictionary(n_neurons) self.__neuron_impl.add_parameters(self._parameters) self.__neuron_impl.add_state_variables(self._state_variables) self.__initial_state_variables = None self.__updated_state_variables = set() # Set up for recording recordable_variables = list( self.__neuron_impl.get_recordable_variables()) record_data_types = dict( self.__neuron_impl.get_recordable_data_types()) self.__neuron_recorder = NeuronRecorder(recordable_variables, record_data_types, [NeuronRecorder.SPIKES], n_neurons) # Set up synapse handling self.__synapse_manager = SynapticManager( self.__neuron_impl.get_n_synapse_types(), ring_buffer_sigma, spikes_per_second, config) # bool for if state has changed. self.__change_requires_mapping = True self.__change_requires_neuron_parameters_reload = False self.__change_requires_data_generation = False self.__has_reset_last = True # Set up for profiling self.__n_profile_samples = helpful_functions.read_config_int( config, "Reports", "n_profile_samples")
def __init__(self, n_neurons, v_thresh): self._units = {V_THRESH: "mV"} self._n_neurons = n_neurons self._data = SpynnakerRangeDictionary(size=n_neurons) self._data[V_THRESH] = v_thresh
def __init__(self, n_neurons, label, constraints, max_atoms_per_core, spikes_per_second, ring_buffer_sigma, incoming_spike_buffer_size, neuron_impl, pynn_model): # pylint: disable=too-many-arguments, too-many-locals super(AbstractPopulationVertex, self).__init__(label, constraints, max_atoms_per_core) self._n_atoms = n_neurons # buffer data self._incoming_spike_buffer_size = incoming_spike_buffer_size # get config from simulator config = globals_variables.get_simulator().config if incoming_spike_buffer_size is None: self._incoming_spike_buffer_size = config.getint( "Simulation", "incoming_spike_buffer_size") self._neuron_impl = neuron_impl self._pynn_model = pynn_model self._parameters = SpynnakerRangeDictionary(n_neurons) self._state_variables = SpynnakerRangeDictionary(n_neurons) self._neuron_impl.add_parameters(self._parameters) self._neuron_impl.add_state_variables(self._state_variables) # Set up for recording recordables = ["spikes"] recordables.extend(self._neuron_impl.get_recordable_variables()) self._neuron_recorder = NeuronRecorder(recordables, n_neurons) self._time_between_requests = config.getint("Buffers", "time_between_requests") self._minimum_buffer_sdram = config.getint("Buffers", "minimum_buffer_sdram") self._using_auto_pause_and_resume = config.getboolean( "Buffers", "use_auto_pause_and_resume") self._receive_buffer_host = config.get("Buffers", "receive_buffer_host") self._receive_buffer_port = helpful_functions.read_config_int( config, "Buffers", "receive_buffer_port") # If live buffering is enabled, set a maximum on the buffer sizes spike_buffer_max_size = 0 variable_buffer_max_size = 0 self._buffer_size_before_receive = None if config.getboolean("Buffers", "enable_buffered_recording"): spike_buffer_max_size = config.getint("Buffers", "spike_buffer_size") variable_buffer_max_size = config.getint("Buffers", "variable_buffer_size") self._maximum_sdram_for_buffering = [spike_buffer_max_size] for _ in self._neuron_impl.get_recordable_variables(): self._maximum_sdram_for_buffering.append(variable_buffer_max_size) # Set up synapse handling self._synapse_manager = SynapticManager( self._neuron_impl.get_n_synapse_types(), ring_buffer_sigma, spikes_per_second, config) # bool for if state has changed. self._change_requires_mapping = True self._change_requires_neuron_parameters_reload = False # Set up for profiling self._n_profile_samples = helpful_functions.read_config_int( config, "Reports", "n_profile_samples")