예제 #1
0
    def test_get_weights(self):
        # Population parameters
        cell_params = {
            'cm': 0.2,  # nF
            'i_offset': 0.2,
            'tau_m': 20.0,
            'tau_refrac': 5.0,
            'tau_syn_E': 5.0,
            'tau_syn_I': 10.0,
            'v_reset': -60.0,
            'v_rest': -60.0,
            'v_thresh': -50.0
        }

        # Reduce number of neurons to simulate on each core
        sim.set_number_of_neurons_per_core(sim.IF_curr_exp, 10)

        # Build inhibitory plasticity  model
        stdp_model = sim.STDPMechanism(
            timing_dependence=sim.SpikePairRule(tau_plus=20.0,
                                                tau_minus=12.7,
                                                nearest=True),
            weight_dependence=sim.AdditiveWeightDependence(w_min=0.0,
                                                           w_max=1.0,
                                                           A_plus=0.05),
            mad=True)

        # Build plastic network
        plastic_ex_pop, plastic_ie_projection =\
            self.build_network(sim.SynapseDynamics(slow=stdp_model),
                               cell_params)

        # Run simulation
        sim.run(1000)

        # Get plastic spikes and save to disk
        plastic_spikes = plastic_ex_pop.getSpikes(compatible_output=True)
        #numpy.save("plastic_spikes.npy", plastic_spikes)

        plastic_weights = plastic_ie_projection.getWeights(format="array")
        #  mean_weight = numpy.average(plastic_weights)

        # End simulation on SpiNNaker
        sim.end()
예제 #2
0
                                                          tau_x=101,
                                                          tau_y=114),
            weight_dependence=sim.AdditiveWeightDependence(
                w_min=0.0,
                w_max=1.0,
                A_plus=param_scale * 0.0,
                A_minus=param_scale * 7.1e-3,
                A3_plus=param_scale * 6.5e-3,
                A3_minus=param_scale * 0.0))

        projections[-1].append(
            sim.Projection(
                pre_pop,
                post_pop,
                sim.OneToOneConnector(weights=start_w),
                synapse_dynamics=sim.SynapseDynamics(slow=stdp_model)))

print("Simulating for %us" % (sim_time / 1000))

# Run simulation
sim.run(sim_time)

# Read weights from each parameter value being tested
weights = []
for projection_delta_t in projections:
    weights.append([p.getWeights()[0] for p in projection_delta_t])

# End simulation on SpiNNaker
sim.end(stop_on_board=True)

#-------------------------------------------------------------------
예제 #3
0
 def start_sim(self,sim_time):
     #simulation setup
     self.simtime = sim_time
     sim.setup(timestep=self.setup_cond["timestep"], min_delay=self.setup_cond["min_delay"], max_delay=self.setup_cond["max_delay"])
     #initialise the neuron population
     spikeArrayOn = {'spike_times': self.in_spike}
     pre_pop = sim.Population(self.pre_pop_size, sim.SpikeSourceArray,
                     spikeArrayOn, label='inputSpikes_On')
     post_pop= sim.Population(self.post_pop_size,sim.IF_curr_exp,
                      self.cell_params_lif, label='post_1')
     stdp_model = sim.STDPMechanism(timing_dependence=sim.SpikePairRule(tau_plus= self.stdp_param["tau_plus"],
                                                 tau_minus= self.stdp_param["tau_minus"],
                                                 nearest=True),
                                     weight_dependence=sim.MultiplicativeWeightDependence(w_min= self.stdp_param["w_min"],
                                                            w_max= self.stdp_param["w_max"],
                                                            A_plus= self.stdp_param["A_plus"],
                                                            A_minus= self.stdp_param["A_minus"]))
     #initialise connectiviity of neurons
     #exitatory connection between pre-synaptic and post-synaptic neuron population                                                              
     if(self.inhibitory_spike_mode):
         connectionsOn  = sim.Projection(pre_pop, post_pop, sim.AllToAllConnector(weights = self.I_syn_weight,delays=1,
                                         allow_self_connections=False),
                                         target='inhibitory')
     else: 
         if(self.STDP_mode):
             if(self.allsameweight):
                 connectionsOn = sim.Projection(pre_pop, post_pop, 
                                            sim.AllToAllConnector(weights = self.E_syn_weight,delays=1),
                                             synapse_dynamics=sim.SynapseDynamics(slow=stdp_model),target='excitatory')
             else:
                 connectionsOn = sim.Projection(pre_pop, post_pop, 
                                            sim.FromListConnector(self.conn_list),
                                             synapse_dynamics=sim.SynapseDynamics(slow=stdp_model),target='excitatory')
         else:
             if(self.allsameweight):
                 connectionsOn  = sim.Projection(pre_pop, post_pop, sim.AllToAllConnector(weights = self.E_syn_weight,delays=1),
                                                                      target='excitatory')
             else:
                 connectionsOn  = sim.Projection(pre_pop, post_pop, sim.FromListConnector(self.conn_list),
                                                                      target='excitatory')
             #sim.Projection.setWeights(self.E_syn_weight)
     
     #inhibitory between the neurons post-synaptic neuron population
     connection_I  = sim.Projection(post_pop, post_pop, sim.AllToAllConnector(weights = self.I_syn_weight,delays=1,
                                                          allow_self_connections=False),
                                                          target='inhibitory')
     pre_pop.record()                                                     
     post_pop.record()
     post_pop.record_v()
     sim.run(self.simtime)
     self.pre_spikes = pre_pop.getSpikes(compatible_output=True)
     self.post_spikes = post_pop.getSpikes(compatible_output=True)
     self.post_spikes_v = post_pop.get_v(compatible_output=True)
     self.trained_weights = connectionsOn.getWeights(format='array')
     sim.end()
     #print self.conn_list
     #print self.trained_weights
     '''scipy.io.savemat('trained_weight.mat',{'initial_weight':self.init_weights,
                                            'trained_weight':self.trained_weights
                                    })'''
     scipy.io.savemat('trained_weight0.mat',{'trained_weight':self.trained_weights
                                    })
                                 MyModelCurrExp, {
                                     "my_parameter": -70.0,
                                     "i_offset": i_offset,
                                 },
                                 label="my_model_pop")
stdp = p.STDPMechanism(timing_dependence=MyTimingDependence(
    my_potentiation_parameter=2.0, my_depression_parameter=0.1),
                       weight_dependence=MyWeightDependence(w_min=0.0,
                                                            w_max=10.0,
                                                            my_parameter=0.5),
                       mad=True)
p.Projection(input_pop, my_model_stdp_pop, p.OneToOneConnector(weights=weight))
stdp_connection = p.Projection(input_pop,
                               my_model_stdp_pop,
                               p.OneToOneConnector(weights=0),
                               synapse_dynamics=p.SynapseDynamics(slow=stdp))

my_model_pop.record_v()
my_model_my_synapse_type_pop.record_v()
my_model_my_additional_input_pop.record_v()
my_model_my_threshold_pop.record_v()

p.run(run_time)

print stdp_connection.getWeights()

create_v_graph(my_model_pop, "My Model")
create_v_graph(my_model_my_synapse_type_pop, "My Model with My Synapse Type")
create_v_graph(my_model_my_additional_input_pop,
               "My Model with My Additional Input")
create_v_graph(my_model_my_threshold_pop, "My Model with My Threshold")
예제 #5
0
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()

예제 #6
0
# | 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
pre_pop.record()
post_pop.record()

# Run simulation
p.run(sim_time)

# Dump data
#pre_pop.printSpikes("results/stdp_pre.spikes")
#post_pop.printSpikes("results/stdp_post.spikes")
#pre_pop.print_v("results/stdp_pre.v")
#post_pop.print_v("results/stdp_post.v")
예제 #7
0
populations.append(
    p.Population(1, p.SpikeSourceArray, spikeArray7, label='inputSpikes_7'))
populations.append(
    p.Population(1, p.SpikeSourceArray, spikeArray8, label='inputSpikes_8'))

projections.append(
    p.Projection(populations[0], populations[0],
                 p.FromListConnector(connections)))
projections.append(
    p.Projection(populations[1], populations[0],
                 p.FromListConnector(injectionConnection)))
projections.append(
    p.Projection(populations[2],
                 populations[0],
                 p.FromListConnector(injectionConnection),
                 synapse_dynamics=p.SynapseDynamics(slow=stdp_model1)))
projections.append(
    p.Projection(populations[3],
                 populations[0],
                 p.FromListConnector(injectionConnection),
                 synapse_dynamics=p.SynapseDynamics(slow=stdp_model2)))
projections.append(
    p.Projection(populations[4],
                 populations[0],
                 p.FromListConnector(injectionConnection),
                 synapse_dynamics=p.SynapseDynamics(slow=stdp_model3)))
# currently only slow SynapseDynamics are supported, therefore fast ones need to
# be removed
#projections.append(p.Projection(populations[5], populations[0],
#                                p.FromListConnector(injectionConnection),
#                                synapse_dynamics=