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 structural_formation_to_full(): p.setup(1.0) stim = p.Population(4, p.SpikeSourceArray(range(10)), label="stim") # These populations should experience formation pop = p.Population(4, p.IF_curr_exp(), label="pop") # Formation with random selection (0 probability elimination), setting # with_replacement=False means an all-to-all connection will be the result proj = p.Projection( stim, pop, p.FromListConnector([]), p.StructuralMechanismStatic( partner_selection=p.LastNeuronSelection(), formation=p.DistanceDependentFormation([2, 2], 1.0), elimination=p.RandomByWeightElimination(4.0, 0, 0), f_rew=1000, initial_weight=4.0, initial_delay=3.0, s_max=4, seed=0, weight=0.0, delay=1.0, with_replacement=False)) pop.record("rewiring") p.run(1000) # Get the final connections conns = 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_f = formation_events.labels[0] p.end() return conns, num_forms, num_elims, first_f
def mission_impossible_2(): sim.setup(0.1, time_scale_factor=1) # Can't do structural on multiple synapse cores source = sim.Population(1, sim.SpikeSourcePoisson(rate=10)) pop = sim.Population(128, sim.IF_curr_exp(), additional_parameters={ "splitter": SplitterAbstractPopulationVertexNeuronsSynapses(2) }) sim.Projection( source, pop, sim.FromListConnector([]), sim.StructuralMechanismStatic(sim.RandomSelection(), sim.DistanceDependentFormation(), sim.RandomByWeightElimination(0.5))) with pytest.raises(SynapticConfigurationException): sim.run(100)
tau_minus=tau_minus, A_plus=a_plus, A_minus=a_minus), weight_dependence=sim.AdditiveWeightDependence(w_min=0, w_max=g_max), backprop_delay=False) elif args.case == CASE_REW_NO_CORR or args.case == CASE_CORR_NO_REW: structure_model_w_stdp = sim.StructuralMechanismStatic( # Partner selection, formation and elimination rules from above partner_selection_last_neuron, formation_distance, elimination_weight, # Use this weight when creating a new synapse initial_weight=g_max, # Use this weight for synapses at start of simulation weight=g_max, # Use this delay when creating a new synapse initial_delay=args.delay, # Use this weight for synapses at the start of simulation delay=args.delay, # Maximum allowed fan-in per target-layer neuron s_max=s_max * 2, # Frequency of rewiring in Hz f_rew=f_rew, # NO STDP rules ) else: raise ValueError("I don't know what {} is supposed to do.".format( args.case)) # if not testing (i.e. training) construct 10 sources + 10 targets # grouped into 2 columns # For each source VRPSS load mnist rates from file
def structural_shared(): p.setup(1.0) pre_spikes = numpy.array(range(0, 10, 2)) A_plus = 0.01 A_minus = 0.01 tau_plus = 20.0 tau_minus = 20.0 w_min = 0.0 w_max = 5.0 w_init = 5.0 delay_init = 2.0 stim = p.Population(1, p.SpikeSourceArray(pre_spikes), label="stim") pop = p.Population(1, p.IF_curr_exp(), label="pop") pop_2 = p.Population(1, p.IF_curr_exp(), label="pop_2") pop_3 = p.Population(1, p.IF_curr_exp(), label="pop_3") pop_4 = p.Population(1, p.IF_curr_exp(), label="pop_4") pop.record("spikes") pop_2.record("spikes") struct_pl_static = p.StructuralMechanismStatic( partner_selection=p.LastNeuronSelection(), formation=p.DistanceDependentFormation([1, 1], 1.0), elimination=p.RandomByWeightElimination(2.0, 0, 0), f_rew=1000, initial_weight=w_init, initial_delay=delay_init, s_max=1, seed=0, weight=0.0, delay=1.0) struct_pl_stdp = p.StructuralMechanismSTDP( partner_selection=p.LastNeuronSelection(), formation=p.DistanceDependentFormation([1, 1], 0.0), elimination=p.RandomByWeightElimination(4.0, 1.0, 1.0), timing_dependence=p.SpikePairRule( tau_plus, tau_minus, A_plus, A_minus), weight_dependence=p.AdditiveWeightDependence(w_min, w_max), f_rew=1000, initial_weight=2.0, initial_delay=5.0, s_max=1, seed=0, weight=0.0, delay=1.0) proj = p.Projection( stim, pop, p.FromListConnector([]), struct_pl_static) proj_2 = p.Projection( stim, pop_2, p.FromListConnector([]), struct_pl_static) proj_3 = p.Projection( stim, pop_3, p.FromListConnector([(0, 0)]), struct_pl_stdp) proj_4 = p.Projection( stim, pop_4, p.FromListConnector([(0, 0)]), struct_pl_stdp) p.Projection(pop_3, pop_4, p.AllToAllConnector(), p.StaticSynapse(weight=1, delay=3)) p.run(10) conns = list(proj.get(["weight", "delay"], "list")) conns_2 = list(proj_2.get(["weight", "delay"], "list")) conns_3 = list(proj_3.get(["weight", "delay"], "list")) conns_4 = list(proj_4.get(["weight", "delay"], "list")) p.end() print(conns) print(conns_2) print(conns_3) print(conns_4) assert(len(conns) == 1) assert(tuple(conns[0]) == (0, 0, w_init, delay_init)) assert(len(conns_2) == 1) assert(tuple(conns_2[0]) == (0, 0, w_init, delay_init)) assert(len(conns_3) == 0) assert(len(conns_4) == 0)
def structural_without_stdp(): p.setup(1.0) stim = p.Population(1, p.SpikeSourceArray(range(10)), label="stim") # These populations should experience formation pop = p.Population(1, p.IF_curr_exp(), label="pop") pop_2 = p.Population(1, p.IF_curr_exp(), label="pop_2") # These populations should experience elimination pop_3 = p.Population(1, p.IF_curr_exp(), label="pop_3") pop_4 = p.Population(1, p.IF_curr_exp(), label="pop_4") # Formation with last-neuron selection (0 probability elimination) proj = p.Projection( stim, pop, p.FromListConnector([]), p.StructuralMechanismStatic( partner_selection=p.LastNeuronSelection(), formation=p.DistanceDependentFormation([1, 1], 1.0), elimination=p.RandomByWeightElimination(2.0, 0, 0), f_rew=1000, initial_weight=2.0, initial_delay=5.0, s_max=1, seed=0, weight=0.0, delay=1.0)) # Formation with random selection (0 probability elimination) proj_2 = p.Projection( stim, pop_2, p.FromListConnector([]), p.StructuralMechanismStatic( partner_selection=p.RandomSelection(), formation=p.DistanceDependentFormation([1, 1], 1.0), elimination=p.RandomByWeightElimination(4.0, 0, 0), f_rew=1000, initial_weight=4.0, initial_delay=3.0, s_max=1, seed=0, weight=0.0, delay=1.0)) # Elimination with last neuron selection (0 probability formation) proj_3 = p.Projection( stim, pop_3, p.FromListConnector([(0, 0)]), p.StructuralMechanismStatic( partner_selection=p.LastNeuronSelection(), formation=p.DistanceDependentFormation([1, 1], 0.0), elimination=p.RandomByWeightElimination(4.0, 1.0, 1.0), f_rew=1000, initial_weight=2.0, initial_delay=5.0, s_max=1, seed=0, weight=0.0, delay=1.0)) # Elimination with random selection (0 probability formation) proj_4 = p.Projection( stim, pop_4, p.FromListConnector([(0, 0)]), p.StructuralMechanismStatic( partner_selection=p.RandomSelection(), formation=p.DistanceDependentFormation([1, 1], 0.0), elimination=p.RandomByWeightElimination(4.0, 1.0, 1.0), f_rew=1000, initial_weight=4.0, initial_delay=3.0, s_max=1, seed=0, weight=0.0, delay=1.0)) p.run(10) # Get the final connections conns = list(proj.get(["weight", "delay"], "list")) conns_2 = list(proj_2.get(["weight", "delay"], "list")) conns_3 = list(proj_3.get(["weight", "delay"], "list")) conns_4 = list(proj_4.get(["weight", "delay"], "list")) p.end() print(conns) print(conns_2) print(conns_3) print(conns_4) # These should be formed with specified parameters assert(len(conns) == 1) assert(tuple(conns[0]) == (0, 0, 2.0, 5.0)) assert(len(conns_2) == 1) assert(tuple(conns_2[0]) == (0, 0, 4.0, 3.0)) # These should have no connections since eliminated assert(len(conns_3) == 0) assert(len(conns_4) == 0)