def test_multiple_connections_between_same_populations(self): p1 = pyNN.Population(no_neurons, pyNN.IF_curr_exp, cell_params_lif, label="LIF Pop") p2 = pyNN.Population(no_neurons, pyNN.IF_curr_exp, cell_params_lif, label="LIF Pop") pyNN.Projection(p1, p2, pyNN.OneToOneConnector(1, 1)) self.assertIsInstance( pyNN.Projection(p1, p2, pyNN.OneToOneConnector(1, 1)), Projection, "Failed to create multiple connections between" " the same pair of populations")
def test_projection_params(self): populations = list() projection_details = list() populations = list() weight_to_spike = 2 delay = 5 populations.append( pyNN.Population(no_neurons, pyNN.IF_curr_exp, cell_params_lif, label="LIF Pop")) populations.append( pyNN.Population(no_neurons, pyNN.IF_curr_dual_exp, cell_params_lif2exp, label="IF_curr_dual_exp Pop")) populations.append( pyNN.Population(no_neurons, pyNN.IF_cond_exp, cell_params_lifexp, label="IF_cond_exp Pop")) populations.append( pyNN.Population(no_neurons, pyNN.IZK_curr_exp, cell_params_izk, label="IZK_curr_exp Pop")) for i in range(4): for j in range(4): projection_details.append({ 'presyn': populations[i], 'postsyn': populations[j], 'connector': pyNN.OneToOneConnector(weight_to_spike, delay) }) projections.append( pyNN.Projection( populations[i], populations[j], pyNN.OneToOneConnector(weight_to_spike, delay))) for i in range(4): for j in range(4): self.assertEqual( projections[i + j]._projection_edge._pre_vertex, projection_details[i + j]['presyn']._vertex) self.assertEqual( projections[i + j]._projection_edge._post_vertex, projection_details[i + j]['postsyn']._vertex)
def test_setup(self): global projections weight_to_spike = 2 delay = 5 populations.append( pyNN.Population(no_neurons, pyNN.IF_curr_exp, cell_params_lif, label="LIF Pop")) populations.append( pyNN.Population(no_neurons, pyNN.IF_curr_dual_exp, cell_params_lif2exp, label="IF_curr_dual_exp Pop")) populations.append( pyNN.Population(no_neurons, pyNN.IF_cond_exp, cell_params_lifexp, label="IF_cond_exp Pop")) populations.append( pyNN.Population(no_neurons, pyNN.IZK_curr_exp, cell_params_izk, label="IZK_curr_exp Pop")) populations.append( pyNN.Population(no_neurons, pyNN.SpikeSourceArray, spike_array, label="SpikeSourceArray Pop")) populations.append( pyNN.Population(no_neurons, pyNN.SpikeSourcePoisson, spike_array_poisson, label="SpikeSourcePoisson Pop")) for i in range(4): projection_details.append({ 'presyn': populations[0], 'postsyn': populations[i], 'connector': pyNN.OneToOneConnector(weight_to_spike, delay) }) projections.append( pyNN.Projection(populations[0], populations[i], pyNN.OneToOneConnector(weight_to_spike, delay)))
def test_source_populations_as_postsynaptic(self): global projections weight_to_spike = 2 delay = 5 with self.assertRaises(exc.ConfigurationException): for i in range(4, 6): projections.append( pyNN.Projection( populations[0], populations[i], pyNN.OneToOneConnector(weight_to_spike, delay)))
def test_recording_numerious_element(self): p.setup(timestep=1.0, min_delay=1.0, max_delay=144.0) n_neurons = 20 # number of neurons in each population p.set_number_of_neurons_per_core("IF_curr_exp", n_neurons / 2) cell_params_lif = { 'cm': 0.25, 'i_offset': 0.0, 'tau_m': 20.0, 'tau_refrac': 2.0, 'tau_syn_E': 5.0, 'tau_syn_I': 5.0, 'v_reset': -70.0, 'v_rest': -65.0, 'v_thresh': -50.0 } populations = list() projections = list() boxed_array = numpy.zeros(shape=(0, 2)) spike_array = list() for neuron_id in range(0, n_neurons): spike_array.append(list()) for random_time in range(0, 20): random_time2 = random.randint(0, 5000) boxed_array = numpy.append(boxed_array, [[neuron_id, random_time2]], axis=0) spike_array[neuron_id].append(random_time) spike_array_params = {'spike_times': spike_array} populations.append( p.Population(n_neurons, p.IF_curr_exp, cell_params_lif, label='pop_1')) populations.append( p.Population(n_neurons, p.SpikeSourceArray, spike_array_params, label='inputSpikes_1')) projections.append( p.Projection(populations[1], populations[0], p.OneToOneConnector())) populations[1].record() p.run(5000) spike_array_spikes = populations[1].getSpikes() boxed_array = boxed_array[numpy.lexsort( (boxed_array[:, 1], boxed_array[:, 0]))] numpy.testing.assert_array_equal(spike_array_spikes, boxed_array) p.end()
def test_inhibitory_connector(self): weight_to_spike = 2 delay = 5 p1 = pyNN.Population(no_neurons, pyNN.IF_curr_exp, cell_params_lif, label="LIF Pop") p2 = pyNN.Population(no_neurons, pyNN.IF_curr_exp, cell_params_lif, label="LIF Pop") s12_2 = pyNN.Projection(p1, p2, pyNN.OneToOneConnector(weight_to_spike, delay), target='inhibitory') s21 = pyNN.Projection(p2, p1, pyNN.OneToOneConnector(weight_to_spike, delay), target='excitatory')
def test_connector_populations_of_different_sizes(self): weight = 2 delay = 5 p1 = pyNN.Population(10, pyNN.IF_curr_exp, cell_params_lif, label="pop 1") p2 = pyNN.Population(5, pyNN.IF_curr_exp, cell_params_lif, label="pop 2") with self.assertRaises(ConfigurationException): pyNN.Projection(p1, p2, pyNN.OneToOneConnector(weight, delay))
def test_one_to_one_connector_from_high_to_low(self): weight_to_spike, delay = 2, 5 second_population = pyNN.Population(no_neurons, pyNN.IF_curr_exp, cell_params_lif, label="LIF Pop") different_population = pyNN.Population( 20, pyNN.IF_curr_exp, cell_params_lif, label="A random sized population") with self.assertRaises(exc.ConfigurationException): pyNN.Projection(different_population, second_population, pyNN.OneToOneConnector(weight_to_spike, delay))
def test_synapse_list_generation_for_different_sized_populations(self): number_of_neurons = 10 first_population = pyNN.Population(number_of_neurons, pyNN.IF_curr_exp, cell_params_lif, label="One pop") second_population = pyNN.Population(number_of_neurons + 5, pyNN.IF_curr_exp, cell_params_lif, label="Second pop") weight = 2 delay = 1 connection = pyNN.OneToOneConnector(weight, delay) with self.assertRaises(ConfigurationException): connection.generate_synapse_list(first_population, second_population, 1, 1.0, 0)
def test_self_connect_population(self): number_of_neurons = 10 first_population = pyNN.Population(number_of_neurons, pyNN.IF_curr_exp, cell_params_lif, label="One pop") weight = 2 delay = 1 synapse_type = 0 connection = pyNN.OneToOneConnector(weight, delay) synaptic_list = connection.generate_synapse_list( first_population, first_population, 1, 1.0, synapse_type) self.assertEqual(synaptic_list.get_max_weight(), weight) self.assertEqual(synaptic_list.get_min_weight(), weight) pp(synaptic_list.get_rows()) self.assertEqual(synaptic_list.get_n_rows(), number_of_neurons) self.assertEqual(synaptic_list.get_max_delay(), delay) self.assertEqual(synaptic_list.get_min_delay(), delay)
def test_recording_poisson_spikes_rate_0(self): p.setup(timestep=1.0, min_delay=1.0, max_delay=144.0) n_neurons = 256 # number of neurons in each population p.set_number_of_neurons_per_core("IF_curr_exp", n_neurons / 2) cell_params_lif = { 'cm': 0.25, 'i_offset': 0.0, 'tau_m': 20.0, 'tau_refrac': 2.0, 'tau_syn_E': 5.0, 'tau_syn_I': 5.0, 'v_reset': -70.0, 'v_rest': -65.0, 'v_thresh': -50.0 } populations = list() projections = list() populations.append( p.Population(n_neurons, p.IF_curr_exp, cell_params_lif, label='pop_1')) populations.append( p.Population(n_neurons, p.SpikeSourcePoisson, {'rate': 0}, label='inputSpikes_1')) projections.append( p.Projection(populations[1], populations[0], p.OneToOneConnector())) populations[1].record() p.run(5000) spikes = populations[1].getSpikes() print spikes p.end()
def simulate(self, spinnaker, input_spike_times): # Cell parameters cell_params = { 'tau_m': 20.0, 'v_rest': -60.0, 'v_reset': -60.0, 'v_thresh': -40.0, 'tau_syn_E': 2.0, 'tau_syn_I': 2.0, 'tau_refrac': 2.0, 'cm': 0.25, 'i_offset': 0.0, } rng = p.NumpyRNG(seed=28375) v_init = p.RandomDistribution('uniform', [-60, -40], rng) p.setup(timestep=1.0, min_delay=1.0, max_delay=10.0) pop = p.Population(1, p.IF_curr_exp, cell_params, label='population') pop.randomInit(v_init) pop.record() pop.record_v() noise = p.Population(1, p.SpikeSourceArray, {"spike_times": input_spike_times}) p.Projection(noise, pop, p.OneToOneConnector(weights=0.4, delays=1), target='excitatory') # Simulate p.run(self.simtime) pop_voltages = pop.get_v(compatible_output=True) pop_spikes = pop.getSpikes(compatible_output=True) p.end() return pop_voltages, pop_spikes
def test_connect_two_different_populations(self): number_of_neurons = 10 first_population = pyNN.Population(number_of_neurons, pyNN.IF_curr_exp, cell_params_lif, label="One pop") second_population = pyNN.Population(number_of_neurons, pyNN.IF_curr_exp, cell_params_lif, label="Second pop") weight = 2 delay = 1 synapse_type = first_population._vertex.get_synapse_id('excitatory') connection = pyNN.OneToOneConnector(weight, delay) synaptic_list = connection.generate_synapse_list( first_population, second_population, 1, 1.0, synapse_type) self.assertEqual(synaptic_list.get_max_weight(), weight) self.assertEqual(synaptic_list.get_min_weight(), weight) pp(synaptic_list.get_rows()) self.assertEqual(synaptic_list.get_n_rows(), number_of_neurons) self.assertEqual(synaptic_list.get_max_delay(), delay) self.assertEqual(synaptic_list.get_min_delay(), delay)
cell_params_lif, label='pop_backward') # Create injection populations injector_forward = Frontend.Population(n_neurons, ExternalDevices.SpikeInjector, cell_params_spike_injector_with_key, label='spike_injector_forward') injector_backward = Frontend.Population(n_neurons, ExternalDevices.SpikeInjector, cell_params_spike_injector, label='spike_injector_backward') # Create a connection from the injector into the populations Frontend.Projection(injector_forward, pop_forward, Frontend.OneToOneConnector(weights=weight_to_spike)) Frontend.Projection(injector_backward, pop_backward, Frontend.OneToOneConnector(weights=weight_to_spike)) # Synfire chain connections where each neuron is connected to its next neuron # NOTE: there is no recurrent connection so that each chain stops once it # reaches the end loop_forward = list() loop_backward = list() for i in range(0, n_neurons - 1): loop_forward.append((i, (i + 1) % n_neurons, weight_to_spike, 3)) loop_backward.append(((i + 1) % n_neurons, i, weight_to_spike, 3)) Frontend.Projection(pop_forward, pop_forward, Frontend.FromListConnector(loop_forward)) Frontend.Projection(pop_backward, pop_backward, Frontend.FromListConnector(loop_backward))
# spindle population spindle_pop = p.Population(n_fibers * 2, MuscleSpindle, { "primary": [1] * n_fibers + [0] * n_fibers, "v_thresh": 100.0, "receive_port": 12345 }, label="spindle_pop") spindle_pop.record() # dynamic fusimotor drive gamma_dyn = p.Population(1, p.SpikeSourcePoisson, {'rate': 70.0}) p.Projection(gamma_dyn, spindle_pop, p.OneToOneConnector(weights=weight), target="dynamic") # static fusimotor drive gamma_st = p.Population(1, p.SpikeSourcePoisson, {'rate': 40.0}) p.Projection(gamma_st, spindle_pop, p.OneToOneConnector(weights=weight), target="static") # database for live communication spynnaker_external_devices = SpynnakerExternalDevicePluginManager() def create_database(): database_notify_port_num = conf.config.getint("Database", "notify_port")
]}) post_stim = sim.Population( pop_size, sim.SpikeSourceArray, { 'spike_times': [ [ i for i in range(pairing_start_time, pairing_end_time, time_between_pairs) ], ] }) # +-------------------------------------------------------------------+ # | Creation of connections | # +-------------------------------------------------------------------+ # Connection type between noise poisson generator and excitatory populations ee_connector = sim.OneToOneConnector(weights=2) sim.Projection(pre_stim, pre_pop, ee_connector, target='excitatory') sim.Projection(post_stim, post_pop, ee_connector, target='excitatory') # Plastic Connections between pre_pop and post_pop stdp_model = sim.STDPMechanism( timing_dependence=sim.SpikePairRule(tau_plus=20.0, tau_minus=50.0), weight_dependence=sim.AdditiveWeightDependence(w_min=0, w_max=1, A_plus=0.02, A_minus=0.02)) sim.Projection(pre_pop, post_pop, sim.OneToOneConnector(),
def test_script(self): """ test that tests the printing of v from a pre determined recording :return: """ p.setup(timestep=0.1, min_delay=1.0, max_delay=14.0) n_neurons = 128 * 128 # number of neurons in each population p.set_number_of_neurons_per_core("IF_cond_exp", 256) cell_params_lif = { 'cm': 0.25, 'i_offset': 0.0, 'tau_m': 20.0, 'tau_refrac': 2.0, 'tau_syn_E': 5.0, 'tau_syn_I': 5.0, 'v_reset': -70.0, 'v_rest': -65.0, 'v_thresh': -50.0, 'e_rev_E': 0., 'e_rev_I': -80. } populations = list() projections = list() weight_to_spike = 0.035 delay = 1.7 spikes = read_spikefile('test.spikes', n_neurons) print spikes spike_array = {'spike_times': spikes} populations.append( p.Population(n_neurons, p.SpikeSourceArray, spike_array, label='inputSpikes_1')) populations.append( p.Population(n_neurons, p.IF_cond_exp, cell_params_lif, label='pop_1')) projections.append( p.Projection( populations[0], populations[1], p.OneToOneConnector(weights=weight_to_spike, delays=delay))) populations[1].record() p.run(100) spikes = populations[1].getSpikes(compatible_output=True) if spikes is not None: print spikes pylab.figure() pylab.plot([i[1] for i in spikes], [i[0] for i in spikes], ".") pylab.xlabel('Time/ms') pylab.ylabel('spikes') pylab.title('spikes') pylab.show() else: print "No spikes received" p.end()
import spynnaker.pyNN as p p.setup(timestep=1.0, min_delay=1.0, max_delay=144.0) nNeurons = 100 #p.set_number_of_neurons_per_core("IF_curr_exp", nNeurons) input = p.Population(1024, p.SpikeSourcePoisson, {'rate': 10}, "input") relay_on = p.Population(1024, p.IF_curr_exp, {}, "input") weight_to_spike = 2.0 delay = 17 t_rule_LGN = p.SpikePairRule (tau_plus=17, tau_minus=34) w_rule_LGN = p.AdditiveWeightDependence (w_min=0.0, w_max=0.3, A_plus=0.01, A_minus=0.0085) stdp_model_LGN = p.STDPMechanism (timing_dependence = t_rule_LGN, weight_dependence = w_rule_LGN) s_d_LGN = p.SynapseDynamics(slow = stdp_model_LGN) in_to_relay_on = p.Projection(input, relay_on, p.OneToOneConnector(weights=1),synapse_dynamics = s_d_LGN, target='excitatory') p.run(1000) p.end()
# | Creation of neuron populations | # +-------------------------------------------------------------------+ # Neuron populations pre_pop = p.Population(pop_size, model, cell_params) post_pop = p.Population(pop_size, model, cell_params) # Stimulating populations pre_stim = p.Population(pop_size, p.SpikeSourceArray, {'spike_times': [[i for i in range(0, sim_time, time_between_pairs)],]}) post_stim = p.Population(pop_size, p.SpikeSourceArray, {'spike_times': [[i for i in range(pairing_start_time, pairing_end_time, time_between_pairs)],]}) # +-------------------------------------------------------------------+ # | Creation of connections | # +-------------------------------------------------------------------+ # Connection type between noise poisson generator and excitatory populations ee_connector = p.OneToOneConnector(weights=2) p.Projection(pre_stim, pre_pop, ee_connector, target='excitatory') p.Projection(post_stim, post_pop, ee_connector, target='excitatory') # Plastic Connections between pre_pop and post_pop stdp_model = p.STDPMechanism( timing_dependence = p.SpikePairRule(tau_plus = 20.0, tau_minus = 50.0), weight_dependence = p.AdditiveWeightDependence(w_min = 0, w_max = 1, A_plus=0.02, A_minus = 0.02) ) p.Projection(pre_pop, post_pop, p.OneToOneConnector(), synapse_dynamics = p.SynapseDynamics(slow= stdp_model) ) # Record spikes
[i[2] for i in v_for_neuron]) p.setup(time_step) input_pop = p.Population(1, p.SpikeSourceArray, {"spike_times": spike_times}, label="input") my_model_pop = p.Population(1, MyModelCurrExp, { "my_parameter": -70.0, "i_offset": i_offset, }, label="my_model_pop") p.Projection(input_pop, my_model_pop, p.OneToOneConnector(weights=weight)) my_model_my_synapse_type_pop = p.Population( 1, MyModelCurrMySynapseType, { "my_parameter": -70.0, "i_offset": i_offset, "my_ex_synapse_parameter": 0.5 }, label="my_model_my_synapse_type_pop") p.Projection(input_pop, my_model_my_synapse_type_pop, p.OneToOneConnector(weights=weight)) my_model_my_additional_input_pop = p.Population( 1, MyModelCurrExpMyAdditionalInput, {
def estimate_kb(cell_params_lif): cell_para = copy.deepcopy(cell_params_lif) random.seed(0) p.setup(timestep=1.0, min_delay=1.0, max_delay=16.0) run_s = 10. runtime = 1000. * run_s max_rate = 1000. ee_connector = p.OneToOneConnector(weights=1.0, delays=2.0) pop_list = [] pop_output = [] pop_source = [] x = np.arange(0., 1.01, 0.1) count = 0 trail = 10 for i in x: for j in range(trail): #trails for average pop_output.append(p.Population(1, p.IF_curr_exp, cell_para)) poisson_spikes = poisson_generator(i * max_rate, 0, runtime) pop_source.append( p.Population(1, p.SpikeSourceArray, {'spike_times': poisson_spikes})) p.Projection(pop_source[count], pop_output[count], ee_connector, target='excitatory') pop_output[count].record() count += 1 count = 0 for i in x: cell_para['i_offset'] = i pop_list.append(p.Population(1, p.IF_curr_exp, cell_para)) pop_list[count].record() count += 1 pop_list[count - 1].record_v() p.run(runtime) rate_I = np.zeros(count) rate_P = np.zeros(count) rate_P_max = np.zeros(count) rate_P_min = np.ones(count) * 1000. for i in range(count): spikes = pop_list[i].getSpikes(compatible_output=True) rate_I[i] = len(spikes) / run_s for j in range(trail): spikes = pop_output[i * trail + j].getSpikes(compatible_output=True) spike_num = len(spikes) / run_s rate_P[i] += spike_num if spike_num > rate_P_max[i]: rate_P_max[i] = spike_num if spike_num < rate_P_min[i]: rate_P_min[i] = spike_num rate_P[i] /= trail ''' #plot_spikes(spikes, 'Current = 10. mA') plt.plot(x, rate_I, label='current',) plt.plot(x, rate_P, label='Poisson input') plt.fill_between(x, rate_P_min, rate_P_max, facecolor = 'green', alpha=0.3) ''' x0 = np.where(rate_P > 1.)[0][0] x1 = 4 k = (rate_P[x1] - rate_P[x0]) / (x[x1] - x[x0]) ''' plt.plot(x, k*(x-x[x0])+rate_P[x0], label='linear') plt.legend(loc='upper left', shadow=True) plt.grid('on') plt.show() ''' p.end() return k, x[x0], rate_P[x0]
def main(): minutes = 0 seconds = 30 milliseconds = 0 run_time = minutes*60*1000 + seconds*1000 + milliseconds weight_to_spike = 4. model = sim.IF_curr_exp cell_params = {'cm' : 0.25, # nF 'i_offset' : 0.0, 'tau_m' : 10.0, 'tau_refrac': 2.0, 'tau_syn_E' : 2.5, 'tau_syn_I' : 2.5, 'v_reset' : -70.0, 'v_rest' : -65.0, 'v_thresh' : -55.4 } # Available resolutions # 16, 32, 64, 128 mode = ExternalDvsEmulatorDevice.MODE_64 cam_res = int(mode) cam_fps = 90 frames_per_saccade = cam_fps/3 - 1 polarity = ExternalDvsEmulatorDevice.MERGED_POLARITY output_type = ExternalDvsEmulatorDevice.OUTPUT_TIME history_weight = 1.0 behaviour = VirtualCam.BEHAVE_ATTENTION vcam = VirtualCam("./mnist", behaviour=behaviour, fps=cam_fps, resolution=cam_res, frames_per_saccade=frames_per_saccade) cam_params = {'mode': mode, 'polarity': polarity, 'threshold': 12, 'adaptive_threshold': False, 'fps': cam_fps, 'inhibition': False, 'output_type': output_type, 'save_spikes': "./spikes_from_cam.pickle", 'history_weight': history_weight, #'device_id': 0, # for an OpenCV webcam device #'device_id': 'path/to/video/file', # to encode pre-recorded video 'device_id': vcam, } if polarity == ExternalDvsEmulatorDevice.MERGED_POLARITY: num_neurons = 2*(cam_res**2) else: num_neurons = cam_res**2 sim.setup(timestep=1.0, min_delay=1.0, max_delay=10.0) target = sim.Population(num_neurons, model, cell_params) stimulation = sim.Population(num_neurons, DvsEmulatorDevice, cam_params, label="Webcam population") connector = sim.OneToOneConnector(weights=weight_to_spike) projection = sim.Projection(stimulation, target, connector) target.record() sim.run(run_time) spikes = target.getSpikes(compatible_output=True) sim.end() #stimulation._vertex.stop() print ("Raster plot of the spikes that Spinnaker echoed back") fig = pylab.figure() spike_times = [spike_time for (neuron_id, spike_time) in spikes] spike_ids = [neuron_id for (neuron_id, spike_time) in spikes] pylab.plot(spike_times, spike_ids, ".", markerfacecolor="None", markeredgecolor="Blue", markersize=3) pylab.show()
pynn.setup(timestep=ts, min_delay=ts, max_delay=2.0 * ts) pop = pynn.Population(size=n_neurons, cellclass=pynn.IF_curr_exp, cellparams={}, label='pop') # The ROS_Spinnaker_Interface just needs to be initialised with these two Spike Source Parameters. ros_interface = ROS_Spinnaker_Interface( n_neurons_source=n_neurons, # number of neurons of the injector population Spike_Source_Class=SpikeSourcePoisson ) # the transfer function ROS Input -> Spikes you want to use. # Build your network, run the simulation and optionally record the spikes and voltages. pynn.Projection(ros_interface, pop, pynn.OneToOneConnector(weights=5, delays=1)) pop.record() pop.record_v() pynn.run(simulation_time) spikes = pop.getSpikes() pynn.end() # Plot import pylab spike_times = [spike[1] for spike in spikes] spike_ids = [spike[0] for spike in spikes]
post_times = generate_fixed_frequency_test_data( f, start_time + t, num_pairs) pre_stim = sim.Population(1, sim.SpikeSourceArray, {'spike_times': [ pre_times, ]}) post_stim = sim.Population(1, sim.SpikeSourceArray, {'spike_times': [ post_times, ]}) # Update simulation time sim_time = max(sim_time, max(max(pre_times), max(post_times)) + 100) # Connections between spike sources and neuron populations ee_connector = sim.OneToOneConnector(weights=2) sim.Projection(pre_stim, pre_pop, ee_connector, target='excitatory') sim.Projection(post_stim, post_pop, ee_connector, target='excitatory') # **HACK** param_scale = 0.5 # Plastic Connection between pre_pop and post_pop # Sjostrom visual cortex min-triplet params stdp_model = sim.STDPMechanism( timing_dependence=sim.PfisterSpikeTripletRule(tau_plus=16.8, tau_minus=33.7, tau_x=101, tau_y=114), weight_dependence=sim.AdditiveWeightDependence( w_min=0.0,
label="INH2INH_conn", target='inhibitory') poisson_rate = 500.0 pop_poisson_exc_p = sim.Population(len(exc_neuron_idx), sim.SpikeSourcePoisson, {"rate": poisson_rate}) pop_poisson_exc_n = sim.Population(len(exc_neuron_idx), sim.SpikeSourcePoisson, {"rate": poisson_rate}) pop_poisson_inh_p = sim.Population(len(inh_neuron_idx), sim.SpikeSourcePoisson, {"rate": poisson_rate}) pop_poisson_inh_n = sim.Population(len(inh_neuron_idx), sim.SpikeSourcePoisson, {"rate": poisson_rate}) poisson_weight = 0.005 sim.Projection(pop_poisson_exc_p, pop_lsm_exc, sim.OneToOneConnector(weights=poisson_weight)) sim.Projection(pop_poisson_exc_n, pop_lsm_exc, sim.OneToOneConnector(weights=-poisson_weight)) sim.Projection(pop_poisson_inh_p, pop_lsm_inh, sim.OneToOneConnector(weights=poisson_weight)) sim.Projection(pop_poisson_inh_n, pop_lsm_inh, sim.OneToOneConnector(weights=-poisson_weight)) # # INPUT - Setup # print "Liquid->Liquid connections... Input Setup" tspk = simulation_timestep * 50 # The neurons spike after 50 time steps! number_of_spikes = 500
def test_inhibitory_connector_memory(self): p.setup(timestep=0.1, min_delay=1, max_delay=10.0) weight_to_spike = 10 delay = 1 cell_params_lif = { 'cm': 0.25, 'i_offset': 0.0, 'tau_m': 20.0, 'tau_refrac': 1.0, 'tau_syn_E': 5.0, 'tau_syn_I': 8.0, 'v_reset': -70.0, 'v_rest': -65.0, 'v_thresh': -50.0 } spike_array = {'spike_times': [0]} mem_access = {'spike_times': [10]} p_initial_spike = p.Population(1, p.SpikeSourceArray, spike_array, label="Initial spike pop") p_mem = p.Population(1, p.IF_curr_exp, cell_params_lif, label="Memory") p_out = p.Population(1, p.IF_curr_exp, cell_params_lif, label="Output") p_bridge = p.Population(1, p.IF_curr_exp, cell_params_lif, label="Bridge") p_inhibitor = p.Population(1, p.IF_curr_exp, cell_params_lif, label="Inhibitor") p_access = p.Population(1, p.SpikeSourceArray, mem_access, label="Access memory spike pop") p_out.record() p_mem.record() p_inhibitor.record() p_initial_spike.record() p_access.record() pr_initial_spike1 = p.Projection( p_initial_spike, p_mem, p.OneToOneConnector(weight_to_spike, delay)) pr_initial_spike2 = p.Projection( p_initial_spike, p_inhibitor, p.OneToOneConnector(weight_to_spike, delay)) pr_mem_access = p.Projection(p_access, p_inhibitor, p.OneToOneConnector( weight_to_spike, delay), target='inhibitory') pr_inhibitor_self = p.Projection( p_inhibitor, p_inhibitor, p.OneToOneConnector(weight_to_spike, delay)) pr_inhibitor_bridge = p.Projection(p_inhibitor, p_bridge, p.OneToOneConnector( weight_to_spike, delay), target='inhibitory') pr_mem_self = p.Projection(p_mem, p_mem, p.OneToOneConnector(weight_to_spike, delay)) pr_mem_bridge = p.Projection( p_mem, p_bridge, p.OneToOneConnector(weight_to_spike, delay)) pr_bridge_output = p.Projection( p_bridge, p_out, p.OneToOneConnector(weight_to_spike, delay)) pr_bridge_inhibitor = p.Projection( p_bridge, p_inhibitor, p.OneToOneConnector(weight_to_spike, delay)) p_mem.record_v() p_mem.record_gsyn() p_mem.record() p.run(30) v = None gsyn = None spikes = None v = p_mem.get_v(compatible_output=True) gsyn = p_mem.get_gsyn(compatible_output=True) spikes = p_mem.getSpikes(compatible_output=True) if spikes != None: print spikes pylab.figure() pylab.plot([i[1] for i in spikes], [i[0] for i in spikes], ".") pylab.xlabel('Time/ms') pylab.ylabel('spikes') pylab.title('spikes') pylab.show() else: print "No spikes received" # Make some graphs ticks = len(v) / 1 if v != None: pylab.figure() pylab.xlabel('Time/ms') pylab.ylabel('v') pylab.title('v') for pos in range(0, 1, 20): v_for_neuron = v[pos * ticks:(pos + 1) * ticks] pylab.plot([i[1] for i in v_for_neuron], [i[2] for i in v_for_neuron]) pylab.show() if gsyn != None: pylab.figure() pylab.xlabel('Time/ms') pylab.ylabel('gsyn') pylab.title('gsyn') for pos in range(0, 1, 20): gsyn_for_neuron = gsyn[pos * ticks:(pos + 1) * ticks] pylab.plot([i[1] for i in gsyn_for_neuron], [i[2] for i in gsyn_for_neuron]) pylab.show() p.end()
w_max=1.0, A_plus=0.1, A_minus=0.5)) # Connections between spike sources and neuron populations ####### SET HERE THE PARALLEL FIBER-PURKINJE CELL LEARNING RULE ee_connector = sim.AllToAllConnector(weights=0.5) projection_pf = sim.Projection( pre_stim, population, ee_connector, synapse_dynamics=sim.SynapseDynamics(slow=stdp_model), target='excitatory') # SET HERE THE TEACHING SIGNAL PROJECTION ee_connector = sim.OneToOneConnector() proj_teaching = sim.Projection(teaching_stim, population, ee_connector, target='supervision') print("Simulating for %us" % (sim_time / 1000)) # Run simulation sim.run(sim_time) # Get weight from each projection end_w = projection_pf.getWeights( ) #[p.getWeights()[0] for p in projections_pf] print end_w
label=spikeInjectionPopLabel1) populations.append(pop_spikes_in_1) pop_spikes_in_2 = spynn.Population(nNeurons2, ExternalDevices.SpikeInjector, cell_params_spike_injector_2, label=spikeInjectionPopLabel2) populations.append(pop_spikes_in_2) pop_spikes_out_1.record() #ExternalDevices.activate_live_output_for(pop_spikes_out_1) pop_spikes_out_2.record() #ExternalDevices.activate_live_output_for(pop_spikes_out_2) projections.append( spynn.Projection(pop_spikes_in_1, pop_spikes_out_1, spynn.OneToOneConnector(weights=weight_to_spike))) projections.append( spynn.Projection(pop_spikes_in_2, pop_spikes_out_2, spynn.OneToOneConnector(weights=weight_to_spike))) spynn.run(runTimeMs + 1000) #add extra second to get all downstream spikes spikes1 = pop_spikes_out_1.getSpikes(compatible_output=True) spikes2 = pop_spikes_out_2.getSpikes(compatible_output=True) #For raster plot of all together, we need to convert neuron ids to be global not local to each pop for j in spikes2: j[0] = j[0] + nNeurons1 totalSpikes = len(spikes1) + len(spikes1) print 'Total spikes generated: ', totalSpikes if totalSpikes > 0:
populations.append( p.Population(1, p.SpikeSourceArray, spikeArray, label='pop_0')) #populations.append(p.Population(nNeurons, p.IF_curr_exp, input_cell_params, label='pop_0')) populations.append( p.Population(nNeurons, p.IF_curr_exp, cell_params_lif, label='pop_1')) populations.append( p.Population(nNeurons, p.IF_curr_exp, cell_params_lif, label='pop_2')) #projections.append(p.Projection(populations[0], populations[1], p.OneToOneConnector(weights=weight_to_spike, delays=delay))) projections.append( p.Projection( populations[0], populations[1], p.AllToAllConnector(weights=weight_to_spike, delays=injection_delay))) projections.append( p.Projection(populations[1], populations[2], p.OneToOneConnector(weights=weight_to_spike, delays=delay))) #projections.append(p.Projection(populations[1], populations[0], p.FromListConnector([(0, 0, weight_to_spike, injection_delay)]))) populations[1].record_v() populations[1].record() p.run(100) v = None gsyn = None spikes = None v = populations[1].get_v(compatible_output=True) spikes = populations[1].getSpikes(compatible_output=True) if spikes != None:
ros_interface = ROS_Spinnaker_Interface( Spike_Sink_Class= SpikeSinkSmoothing, # the transfer function Spikes -> ROS Output you want to use. # You can choose from the transfer_functions module # or write one yourself. output_population=pop) # the pynn population you wish to receive the # live spikes from. # Notice that ros_interface will now be None, because there is no SpikeInjector for receiver only. # You need a different Spike Source. # Build your network, run the simulation and optionally record the spikes and voltages. spike_source = pynn.Population(n_neurons, pynn.SpikeSourcePoisson, {'rate': 10}) pynn.Projection(spike_source, pop, pynn.OneToOneConnector(weights=5, delays=1)) pop.record() pop.record_v() pynn.run(simulation_time) spikes = pop.getSpikes() pynn.end() # Plot import pylab spike_times = [spike[1] for spike in spikes] spike_ids = [spike[0] for spike in spikes]