def get_before_run(self): sim.setup(1.0) pop1 = sim.Population(3, sim.IF_curr_exp(), label="pop1") pop2 = sim.Population(3, sim.IF_curr_exp(), label="pop2") synapse_type = sim.StaticSynapse(weight=5, delay=1) projection = sim.Projection( pop1, pop2, sim.AllToAllConnector(), synapse_type=synapse_type) weights = projection.get(["weight"], "list") sim.run(0) length = len(weights) self.assertEqual(9, length) sim.end()
def run_forever_not_recorded(): sim.setup(1.0) stim = sim.Population(1, sim.SpikeSourcePoisson(rate=10.0)) pop = sim.Population(255, sim.IF_curr_exp(tau_syn_E=1.0), label="pop") sim.Projection(stim, pop, sim.AllToAllConnector(), sim.StaticSynapse(weight=20.0)) conn = DatabaseConnection(start_resume_callback_function=start_callback, stop_pause_callback_function=stop_callback, local_port=None) SpynnakerExternalDevicePluginManager.add_database_socket_address( conn.local_ip_address, conn.local_port, None) sim.external_devices.run_forever() sim.end()
def testReset_add(self): sim.setup(timestep=1.0) sim.set_number_of_neurons_per_core(sim.IF_curr_exp, 1) input = sim.Population( 1, sim.SpikeSourceArray(spike_times=[0]), label="input") pop_1 = sim.Population(2, sim.IF_curr_exp(), label="pop_1") sim.Projection(input, pop_1, sim.AllToAllConnector(), synapse_type=sim.StaticSynapse(weight=5, delay=1)) sim.run(10) sim.Population(2, sim.IF_curr_exp(), label="pop_2") with self.assertRaises(NotImplementedError): sim.run(10)
def run_network(timestep, steps_per_timestep): p.setup(timestep, max_delay=1.0) pre = p.Population(1, p.SpikeSourceArray(range(0, 100, 10))) post = p.Population(1, p.IF_cond_exp(), additional_parameters={ "n_steps_per_timestep": steps_per_timestep}) post.record(["v", "spikes"]) p.Projection(pre, post, p.AllToAllConnector(), p.StaticSynapse(weight=0.13)) p.run(100) v = post.get_data("v").segments[0].filter(name='v')[0] spikes = post.get_data("spikes").segments[0].spiketrains p.end() return v, spikes
def __run_sim(self, run_times, populations, projections, run_count, spike_times_list, extract_between_runs, get_spikes, record_7, get_v, record_v_7, get_gsyn_exc, record_gsyn_exc_7, get_gsyn_inh, record_gsyn_inh_7, record_input_spikes, record_input_spikes_7, get_all, get_weights, get_delays, new_pop, n_neurons, cell_class, cell_params, weight_to_spike, set_between_runs, reset): results = () for runtime in run_times[:-1]: # This looks strange but is to allow getting data before run if runtime > 0: p.run(runtime) run_count += 1 if extract_between_runs: self._get_data(populations[0], populations[1], get_spikes, record_7, get_v, record_v_7, get_gsyn_exc, record_gsyn_exc_7, get_gsyn_inh, record_gsyn_inh_7, record_input_spikes, record_input_spikes_7, get_all) self._get_weight_delay(projections[0], get_weights, get_delays) if new_pop: populations.append( p.Population(n_neurons, cell_class(**cell_params), label='pop_2')) injection_connection = [(n_neurons - 1, 0, weight_to_spike, 1)] new_projection = p.Projection( populations[0], populations[2], p.FromListConnector(injection_connection), p.StaticSynapse(weight=weight_to_spike, delay=1)) projections.append(new_projection) if spike_times_list is not None: populations[1].set(spike_times=spike_times_list[run_count]) for (pop, name, value) in set_between_runs: new_values = {name: value} populations[pop].set(**new_values) if reset: p.reset() p.run(run_times[-1]) self._default_report_folder = \ p.globals_variables.get_simulator()._report_default_directory return results
def do_bitfield_run(): n_source = 40 n_target = 16 n_neurons = 50 n_boards = math.ceil((n_source + n_target) / 16 / 48) sim.setup(timestep=1.0, n_boards_required=n_boards) try: machine = sim.get_machine() except ConfigurationException as oops: if "Failure to detect machine " in str(oops): raise SkipTest( "You Need at least {} boards to run this test".format( n_boards)) from oops raise oops target_x, target_y = find_good_chip(machine, n_target) print(machine) print(target_x, target_y) sources = [] for s in range(n_source): sources.append( sim.Population(n_neurons, sim.IF_curr_exp(), label="source_{}".format(s))) targets = [] for t in range(n_target): pop = sim.Population(n_neurons, sim.IF_curr_exp(), label="target_{}".format(t), additional_parameters={ "splitter": SplitterAbstractPopulationVertexSlice() }) pop.add_placement_constraint(x=target_x, y=target_y) targets.append(pop) for s in range(n_source): for t in range(n_target): weird_list = [] for i in range(n_neurons): if (s + i) % (t + 1) == 0: weird_list.append([i, i]) sim.Projection(sources[s], targets[t], sim.FromListConnector(weird_list), synapse_type=sim.StaticSynapse(weight=5, delay=1), receptor_type="inhibitory") sim.run(1) sim.end()
def test_run(self): sim.setup() sim.Population(3, sim.SpikeSourcePoisson, {"rate": 100}) p2 = sim.Population(3, sim.SpikeSourceArray, {"spike_times": [[10.0], [20.0], [30.0]]}) p3 = sim.Population(4, sim.IF_cond_exp, {}) sim.Projection(p2, p3, sim.FromListConnector([ (0, 0, 0.1, 1.0), (1, 1, 0.1, 1.0), (2, 2, 0.1, 1.0)])) sim.run(100.0) sim.end()
def check_self_connect(self, connections, with_replacement, allow_self_connections): sim.setup(1.0) pop = sim.Population(DESTINATIONS, sim.IF_curr_exp(), label="pop") synapse_type = sim.StaticSynapse(weight=5, delay=1) projection = sim.Projection( pop, pop, sim.FixedNumberPreConnector( connections, with_replacement=with_replacement, allow_self_connections=allow_self_connections), synapse_type=synapse_type) sim.run(0) self.check_weights(projection, connections, with_replacement, allow_self_connections) sim.end()
def fixedprob_population_views(self): sim.setup(timestep=1.0) in_pop = sim.Population(4, sim.SpikeSourceArray([0]), label="in_pop") pop = sim.Population(4, sim.IF_curr_exp(), label="pop") rng = NumpyRNG(seed=1) conn = sim.Projection(in_pop[1:3], pop[2:4], sim.FixedProbabilityConnector(0.5, rng=rng), sim.StaticSynapse(weight=0.5, delay=2)) sim.run(1) weights = conn.get(['weight', 'delay'], 'list') sim.end() # The fixed seed means this gives the same answer each time target = [[1, 3, 0.5, 2.], [2, 2, 0.5, 2.], [2, 3, 0.5, 2]] self.assertCountEqual(weights, target)
def test_cause_error(self): with self.assertRaises(ConfigurationException): sim.setup(timestep=1.0) sim.set_number_of_neurons_per_core(sim.IF_curr_exp, 100) pop_1 = sim.Population(1, sim.IF_curr_exp(), label="pop_1") input = sim.Population(1, sim.SpikeSourceArray(spike_times=[0]), label="input") sim.Projection(input, pop_1, sim.OneToOneConnector(), synapse_type=sim.StaticSynapse(weight=5, delay=1)) simtime = 10 sim.run(simtime) pop_1.get_data(variables=["v"])
def simple_script(self): # A simple script that should work whatever we do, but only if the # SDRAM is worked out correctly! p.setup(1.0) src = p.Population(1, p.SpikeSourceArray([50, 150]), label="input_pop") pop = p.Population(1, p.IF_curr_exp(), label="neuron") p.Projection(src, pop, p.OneToOneConnector(), synapse_type=p.StaticSynapse(weight=1.0)) src.record('spikes') pop.record("all") p.run(200) p.end()
def using_static_synapse_singles(self): sim.setup(timestep=1.0) input = sim.Population(2, sim.SpikeSourceArray([0]), label="input") pop = sim.Population(2, sim.IF_curr_exp(), label="pop") conn = sim.Projection(input, pop, sim.AllToAllConnector(), sim.StaticSynapse(weight=0.7, delay=3)) sim.run(1) weights = conn.get(['weight', 'delay'], 'list') sim.end() target = [(0, 0, 0.7, 3), (0, 1, 3, 33), (1, 0, 0.4, 12), (1, 1, 0.5, 21)] for i in range(2): for j in range(2): self.assertAlmostEqual(weights[i][j], target[i][j], places=3)
def record_all(self): sim.setup(timestep=1) simtime = 100 input = sim.Population(1, sim.SpikeSourceArray(spike_times=[0, 30]), label="input") pop = sim.Population(32, sim.IF_curr_exp(), label="pop") sim.Projection(input, pop, sim.AllToAllConnector(), synapse_type=sim.StaticSynapse(weight=5, delay=1)) pop.record("all") sim.run(simtime) neo = pop.get_data("all") pop.write_data(pickle_path, "all") io = PickleIO(filename=pickle_path) all_saved = io.read()[0] neo_compare.compare_blocks(neo, all_saved) assert len(neo.segments[0].spiketrains) > 0 assert len(neo.segments[0].filter(name="v")) > 0 assert len(neo.segments[0].filter(name="gsyn_exc")) > 0 spikes_neo = pop.get_data("spikes") pop.write_data(pickle_path, "spikes") io = PickleIO(filename=pickle_path) spikes_saved = io.read()[0] neo_compare.compare_blocks(spikes_neo, spikes_saved) assert len(spikes_neo.segments[0].spiketrains) > 0 assert len(spikes_neo.segments[0].filter(name="v")) == 0 assert len(spikes_neo.segments[0].filter(name="gsyn_exc")) == 0 v_neo = pop.get_data("v") pop.write_data(pickle_path, "v") io = PickleIO(filename=pickle_path) v_saved = io.read()[0] neo_compare.compare_blocks(v_neo, v_saved) assert len(v_neo.segments[0].spiketrains) == 0 assert len(v_neo.segments[0].filter(name="v")) > 0 assert len(v_neo.segments[0].filter(name="gsyn_exc")) == 0 gsyn_neo = pop.get_data("gsyn_exc") pop.write_data(pickle_path, "gsyn_exc") io = PickleIO(filename=pickle_path) gsyn_saved = io.read()[0] neo_compare.compare_blocks(gsyn_neo, gsyn_saved) assert len(gsyn_neo.segments[0].spiketrains) == 0 assert len(spikes_neo.segments[0].filter(name="v")) == 0 assert len(gsyn_neo.segments[0].filter(name="gsyn_exc")) > 0
def live_neuron_voltage(): p.setup(1.0) run_time = 1000.0 create_edges = False time_1 = 10 key_1 = 0x1 devices_1 = [Device(key_1, time_1, "DEVICE_1")] translator_1 = Translator(devices_1) model_1 = p.external_devices.ExternalDeviceLifControl( devices_1, create_edges, translator_1) time_2_1 = 5 key_2_1 = 0xE time_2_2 = 3 key_2_2 = 0xF devices_2 = [Device(key_2_1, time_2_1, "DEVICE_1"), Device(key_2_2, time_2_2, "DEVICE_2")] translator_2 = Translator(devices_2) model_2 = p.external_devices.ExternalDeviceLifControl( devices_2, create_edges, translator_2) conn = p.external_devices.SpynnakerLiveSpikesConnection( receive_labels=["stim"], local_port=None) conn.add_receive_callback("stim", spike_receiver) stim = p.Population(1, p.SpikeSourceArray(range(0, 1000, 100)), label="stim") p.external_devices.activate_live_output_for( stim, database_notify_port_num=conn.local_port) ext_pop = p.external_devices.EthernetControlPopulation( len(devices_1), model_1) ext_pop.record(["v"]) ext_pop_2 = p.external_devices.EthernetControlPopulation( len(devices_2), model_2) ext_pop_2.record(["v"]) p.Projection( stim, ext_pop, p.OneToOneConnector(), p.StaticSynapse(1.0, 1.0)) p.run(run_time) v = ext_pop.get_data("v").segments[0].analogsignals[0].as_array()[:, 0] p.end() relevant_v = v[1:1000:time_1] print(v) print(relevant_v) print(len(translator_1.voltages[key_1]), translator_1.voltages[key_1]) print(len(translator_2.voltages[key_2_1]), translator_2.voltages[key_2_1]) print(len(translator_2.voltages[key_2_2]), translator_2.voltages[key_2_2]) assert(len(translator_1.voltages[key_1]) == run_time // time_1) assert(len(translator_2.voltages[key_2_1]) == run_time // time_2_1) assert(len(translator_2.voltages[key_2_2]) == run_time // time_2_2) assert(numpy.array_equal(relevant_v, translator_1.voltages[key_1])) assert(numpy.sum(translator_2.voltages[key_2_1]) == 0) assert(numpy.sum(translator_2.voltages[key_2_2]) == 0)
def do_run(): p.setup(timestep=1.0) # The larger population needs to be first for this test inp1 = p.Population(10, p.SpikeSourceArray(spike_times=[0])) out1 = p.Population(10, p.IF_curr_exp()) inp2 = p.Population(5, p.SpikeSourceArray(spike_times=[0])) out2 = p.Population(5, p.IF_curr_exp()) # Using an AllToAll to avoid the OneToOne's direct matrix connector = p.AllToAllConnector() proj_1 = p.Projection(inp1, out1, connector, p.StaticSynapse(weight=2.0, delay=4.0)) proj_2 = p.Projection(inp2, out2, connector, p.StaticSynapse(weight=1.0, delay=3.0)) p.run(1) proj_1_list = proj_1.get(("weight", "delay"), "list") proj_2_list = proj_2.get(("weight", "delay"), "list") p.end() return proj_1_list, proj_2_list
def do_one_to_one_conductance_test(self, neurons_per_core, pre_size, post_size, weight, delay): sim.setup(1.0) sim.set_number_of_neurons_per_core(sim.IF_cond_exp, neurons_per_core) pre = sim.Population(pre_size, sim.IF_cond_exp()) post = sim.Population(post_size, sim.IF_cond_exp()) proj = sim.Projection(pre, post, sim.OneToOneConnector(), sim.StaticSynapse(weight=weight, delay=delay)) sim.run(0) conns = proj.get(["weight", "delay"], "list") sim.end() for pre, post, w, d in conns: assert pre == post assert numpy.allclose(w, weight, rtol=0.0001) assert d == delay
def fixedpost_population_views(self): sim.setup(timestep=1.0) in_pop = sim.Population(4, sim.SpikeSourceArray([0]), label="in_pop") pop = sim.Population(4, sim.IF_curr_exp(), label="pop") rng = NumpyRNG(seed=1) conn = sim.Projection(in_pop[0:3], pop[1:4], sim.FixedNumberPostConnector(2, rng=rng), sim.StaticSynapse(weight=0.5, delay=2)) sim.run(1) weights = conn.get(['weight', 'delay'], 'list') sim.end() # The fixed seed means this gives the same answer each time target = [(0, 1, 0.5, 2.0), (0, 3, 0.5, 2.0), (1, 1, 0.5, 2.0), (1, 3, 0.5, 2.0), (2, 1, 0.5, 2.0), (2, 2, 0.5, 2.0)] self.assertEqual(weights.tolist(), target)
def do_run(self): with LogCapture() as lc: sim.setup(1.0) pop = sim.Population(1, sim.IF_curr_exp, {}, label="pop") inp = sim.Population(1, sim.SpikeSourceArray(spike_times=[0]), label="input") sim.Projection(inp, pop, sim.OneToOneConnector(), synapse_type=sim.StaticSynapse(weight=5)) sim.run(10) self.assert_logs_messages(lc.records, "Working out if machine is booted", 'INFO', 1)
def build_network(stdp_model): # SpiNNaker setup sim.setup(timestep=1.0, min_delay=1.0, max_delay=10.0) # Reduce number of neurons to simulate on each core sim.set_number_of_neurons_per_core(sim.IF_curr_exp, 10) # Create excitatory and inhibitory populations of neurons ex_pop = sim.Population(NUM_EXCITATORY, model(**cell_params)) in_pop = sim.Population(NUM_EXCITATORY / 4, model(**cell_params)) # Record excitatory spikes ex_pop.record(['spikes']) # Make excitatory->inhibitory projections sim.Projection(ex_pop, in_pop, sim.FixedProbabilityConnector(0.02), receptor_type='excitatory', synapse_type=sim.StaticSynapse(weight=0.03)) sim.Projection(ex_pop, ex_pop, sim.FixedProbabilityConnector(0.02), receptor_type='excitatory', synapse_type=sim.StaticSynapse(weight=0.03)) # Make inhibitory->inhibitory projections sim.Projection(in_pop, in_pop, sim.FixedProbabilityConnector(0.02), receptor_type='inhibitory', synapse_type=sim.StaticSynapse(weight=-0.3)) # Make inhibitory->excitatory projections ie_projection = sim.Projection( in_pop, ex_pop, sim.FixedProbabilityConnector(0.02), receptor_type='inhibitory', synapse_type=stdp_model) return ex_pop, ie_projection
def projection_with_reset(self): p.setup(1.0) inp = p.Population(1, p.IF_curr_exp(), label="input") layer = p.Population(1, p.IF_curr_exp(), label="layer") output = p.Population(1, p.IF_curr_exp(), label="output") p.Projection(inp, layer, p.AllToAllConnector(), p.StaticSynapse(weight=5, delay=2)) p.run(100) layer_to_output = p.Projection(layer, output, p.AllToAllConnector(), p.StaticSynapse(weight=4, delay=10)) p.reset() p.run(100) weights_delays_out = layer_to_output.get(["weight", "delay"], "list") p.end() assert weights_delays_out[0][2] == 4.0
def do_run(): """ test that tests the printing of v from a pre determined recording :return: """ p.setup(timestep=1.0, min_delay=1.0, max_delay=144.0) n_neurons = 128 * 128 # number of neurons in each population p.set_number_of_neurons_per_core(p.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 = 17 spikes = read_spikefile('test.spikes', n_neurons) 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(), synapse_type=p.StaticSynapse(weight=weight_to_spike, delay=delay))) populations[1].record("spikes") p.run(1000) spikes = populations[1].spinnaker_get_data('spikes') p.end() return spikes
def create_edge(): if projection_type == "all_to_all" and isinstance( nodes[edge["output"]["id"]], pynn.Population): assert (edge['projection_target']['kind'] == 'static' ) # only support static connectivity for now target = edge['projection_target']['effect'] projection = pynn.Projection(nodes[edge["input"]["id"]], nodes[edge["output"]["id"]], method=pynn.AllToAllConnector(), target=target) weight = edge["projection_type"]["weight"] if edge['projection_target']['effect'] == 'inhibitory' and weight > 0: weight = weight * -1 projection.setWeights(weight) else: print "not yet supported"
def do_run(self): sim.setup(timestep=1.0) sim.set_number_of_neurons_per_core(sim.IF_curr_exp, neurons_per_core) input_spikes = list(range(0, simtime - 100, 10)) expected_spikes = len(input_spikes) input = sim.Population( 1, sim.SpikeSourceArray(spike_times=input_spikes), label="input") pop_1 = sim.Population(n_neurons, sim.IF_curr_exp(), label="pop_1") sim.Projection(input, pop_1, sim.AllToAllConnector(), synapse_type=sim.StaticSynapse(weight=5, delay=1)) pop_1.record(["spikes", "v", "gsyn_exc"]) sim.run(simtime//4*3) sim.run(simtime//4) check_data(pop_1, expected_spikes, simtime) sim.end()
def test_using_static_synapse_doubles(self): sim.setup(timestep=1.0) input = sim.Population(2, sim.SpikeSourceArray([0]), label="input") pop = sim.Population(2, sim.IF_curr_exp(), label="pop") as_list = [(0, 0), (1, 1)] conn = sim.Projection( input, pop, sim.FromListConnector(as_list), sim.StaticSynapse(weight=[0.7, 0.3], delay=[3, 33])) sim.run(1) weights = conn.get(['weight', 'delay'], 'list') target = [(0, 0, 0.7, 3), (1, 1, 0.3, 33)] for i in range(2): for j in range(2): self.assertAlmostEqual(weights[i][j], target[i][j], places=3) sim.end()
def do_run(split, seed=None): p.setup(1.0) if split: p.set_number_of_neurons_per_core(p.SpikeSourcePoisson, 27) p.set_number_of_neurons_per_core(p.IF_curr_exp, 22) inp = p.Population(100, p.SpikeSourcePoisson(rate=100, seed=seed), label="input") pop = p.Population(100, p.IF_curr_exp, {}, label="pop") p.Projection(inp, pop, p.OneToOneConnector(), synapse_type=p.StaticSynapse(weight=5)) pop.record("spikes") inp.record("spikes") p.run(100) inp.set(rate=10) # pop.set("cm", 0.25) pop.set(tau_syn_E=1) p.run(100) pop_spikes1 = pop.spinnaker_get_data('spikes') inp_spikes1 = inp.spinnaker_get_data('spikes') p.reset() inp.set(rate=0) pop.set(i_offset=1.0) vs = p.RandomDistribution("uniform", [-65.0, -55.0], rng=NumpyRNG(seed=seed)) pop.initialize(v=vs) p.run(100) pop_spikes2 = pop.spinnaker_get_data('spikes') inp_spikes2 = inp.spinnaker_get_data('spikes') p.end() return (pop_spikes1, inp_spikes1, pop_spikes2, inp_spikes2)
def structural_eliminate_to_empty(): p.setup(1.0) stim = p.Population(9, p.SpikeSourceArray(range(10)), label="stim") # These populations should experience elimination pop = p.Population(9, p.IF_curr_exp(), label="pop") # Make a full list # Elimination with random selection (0 probability formation) proj = p.Projection( stim, pop, p.AllToAllConnector(), p.StructuralMechanismStatic( partner_selection=p.RandomSelection(), formation=p.DistanceDependentFormation([3, 3], 0.0), elimination=p.RandomByWeightElimination(4.0, 1.0, 1.0), f_rew=1000, initial_weight=4.0, initial_delay=3.0, s_max=9, seed=0, weight=0.0, delay=1.0)) pop.record("rewiring") p.run(1000) # Get the final connections conns = list(proj.get(["weight", "delay"], "list")) rewiring = pop.get_data("rewiring") formation_events = rewiring.segments[0].events[0] elimination_events = rewiring.segments[0].events[1] num_forms = len(formation_events.times) num_elims = len(elimination_events.times) first_elim = elimination_events.labels[0] p.end() # These should have no connections since all should be eliminated assert (len(conns) == 0) assert (num_elims == 81) assert (num_forms == 0) assert (first_elim == "7_5_elimination")
def __init__(self, dvs_input, sim_t, w_kc2kc=0): self.w_kc2kc = w_kc2kc self.sim_t = sim_t self.pn_neuron_idx = range(0, nb_pn, nb_pn / 5) self.kc_neuron_idx = range(0, nb_kc, nb_kc / 10) self.spike_source = sim.Population( nb_pn, sim.SpikeSourceArray(spike_times=dvs_input), label="DVS") self.pns = sim.Population(nb_pn, model(**cell_params), label="PN") self.kcs = sim.Population(nb_kc, model(**cell_params), label="KC") self.kcs_a = sim.Population(nb_kc, model(**cell_params), label="KC_A") self.ens = sim.Population(nb_en, model(**cell_params), label="EN") self.ens_a = sim.Population(nb_en, model(**cell_params), label="EN_A") self.dvs2pn = sim.Projection(self.spike_source, self.pns, sim.OneToOneConnector(), sim.StaticSynapse(weight=0.3, delay=1.0), receptor_type='excitatory') self.pn2kc = sim.Projection(self.pns, self.kcs, sim.FixedTotalNumberConnector(nb_pn2kc * nb_kc), sim.StaticSynapse(weight=0.3, delay=1.0), receptor_type='excitatory') self.pn2kc_a = sim.Projection(self.pns, self.kcs_a, sim.FixedTotalNumberConnector(nb_pn2kc * nb_kc), sim.StaticSynapse(weight=0.3, delay=1.0), receptor_type='excitatory') self.kc2en = sim.Projection(self.kcs, self.ens, sim.AllToAllConnector(), sim.StaticSynapse(weight=0.15, delay=1.0), receptor_type='excitatory') self.kc_a2en_a = sim.Projection(self.kcs_a, self.ens_a, sim.AllToAllConnector(), sim.StaticSynapse(weight=0.15, delay=1.0), receptor_type='excitatory') self.kc_a2kc_a = sim.Projection(self.kcs, self.kcs_a, sim.AllToAllConnector(), sim.StaticSynapse(weight=0.1, delay=1.0), receptor_type='excitatory') self.ens.record(['v', 'spikes']) self.ens_a.record(['v', 'spikes'])
def check_other_connect(self, connections, with_replacement): sim.setup(1.0) pop1 = sim.Population(SOURCES, sim.IF_curr_exp(), label="pop1") pop2 = sim.Population(DESTINATIONS, sim.IF_curr_exp(), label="pop2") synapse_type = sim.StaticSynapse(weight=5, delay=1) projection = sim.Projection(pop1, pop2, sim.FixedNumberPostConnector( connections, with_replacement=with_replacement), synapse_type=synapse_type) sim.run(0) self.check_weights(projection, connections, with_replacement, allow_self_connections=True) sim.end()
def test_check_connection_estimates(self): # Test that the estimates for connections per neuron/vertex work sim.setup(timestep=1.0) n_neurons = 25 pop1 = sim.Population(n_neurons, sim.IF_curr_exp(), label="pop_1") pop2 = sim.Population(n_neurons, sim.IF_curr_exp(), label="pop_2") projection = sim.Projection(pop1, pop2, sim.FixedNumberPostConnector(n_neurons // 2), synapse_type=sim.StaticSynapse(weight=5, delay=1)) simtime = 10 sim.run(simtime) weights = projection.get(["weight"], "list") self.assertEqual(n_neurons * int(n_neurons / 2), len(weights)) sim.end()
def recording_1_element(self): p.setup(timestep=1.0, min_delay=1.0, max_delay=144.0) n_neurons = 200 # number of neurons in each population p.set_number_of_neurons_per_core(p.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() spike_array = {'spike_times': [[0]]} populations.append( p.Population(n_neurons, p.IF_curr_exp, cell_params_lif, label='pop_1')) populations.append( p.Population(1, p.SpikeSourceArray, spike_array, label='inputSpikes_1')) projections.append( p.Projection(populations[1], populations[0], p.AllToAllConnector())) populations[1].record("spikes") p.run(5000) spike_array_spikes = populations[1].spinnaker_get_data("spikes") boxed_array = numpy.zeros(shape=(0, 2)) boxed_array = numpy.append(boxed_array, [[0, 0]], axis=0) numpy.testing.assert_array_equal(spike_array_spikes, boxed_array) p.end()