Esempio n. 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()
Esempio n. 2
0
        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,
                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)
Esempio n. 3
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()

Esempio n. 4
0
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
pre_pop.record()
post_pop.record()

# Run simulation
p.run(sim_time)

# Dump data
#pre_pop.printSpikes("results/stdp_pre.spikes")
Esempio n. 5
0
print spike_times, len(spike_times)
pre_stim = sim.Population(len(spike_times), sim.SpikeSourceArray,
                          {'spike_times': spike_times})

teaching_stim = sim.Population(1, sim.SpikeSourceArray,
                               {'spike_times': [teaching_time]})

# Neuron populations
population = sim.Population(1, model, cell_params)

# Plastic Connection between pre_pop and post_pop
stdp_model = sim.STDPMechanism(
    timing_dependence=cer.TimingDependenceCerebellum(tau=tau,
                                                     peak_time=peak_time),
    weight_dependence=sim.AdditiveWeightDependence(w_min=0.0,
                                                   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,
Esempio n. 6
0
post_pop = sim.Population(pop_size, model, cell_params, label="post")
#post_pop.set_mapping_constraint({"x": 1, "y": 0})
# Stimulating populations
pre_stim = sim.Population(pop_size, sim.SpikeSourcePoisson, {'rate': 5})
#pre_stim.set_mapping_constraint({"x": 1, "y": 1})

# +-------------------------------------------------------------------+
# | Creation of connections                                           |
# +-------------------------------------------------------------------+
# Connection type between noise poisson generator and presynaptic populations
#sim.Projection(pre_stim, pre_pop, sim.FixedProbabilityConnector(0.1, weights=.5))
# Pre to Post (inlcuding defninition of STDP model)
stdp_model = sim.STDPMechanism(
    timing_dependence=sim.SpikePairRule(tau_plus=20.0, tau_minus=20.0),
    weight_dependence=sim.AdditiveWeightDependence(w_min=0,
                                                   w_max=1,
                                                   A_plus=0.2,
                                                   A_minus=0.2))
variableWeights = sim.Projection(
    pre_pop,
    post_pop,
    sim.FixedProbabilityConnector(0.1, weights=.5),
    synapse_dynamics=sim.SynapseDynamics(slow=stdp_model))

# Record spikes
pre_stim.record()
pre_pop.record()
post_pop.record()

# Run simulation
sim.run(sim_time)
Esempio n. 7
0
weight_to_spike = 2.0
delay = 1

connections = list()
for i in range(0, nNeurons):
    singleConnection = (i, ((i + 1) % nNeurons), weight_to_spike, delay)
    connections.append(singleConnection)

# Plastic Connection between pre_pop and post_pop
stdp_model1 = p.STDPMechanism(timing_dependence=p.SpikePairRule(tau_plus=16.7,
                                                                tau_minus=33.7,
                                                                nearest=True),
                              weight_dependence=p.AdditiveWeightDependence(
                                  w_min=0.0,
                                  w_max=1.0,
                                  A_plus=0.005,
                                  A_minus=0.005),
                              mad=True)

# Plastic Connection between pre_pop and post_pop
stdp_model2 = p.STDPMechanism(
    timing_dependence=p.PfisterSpikeTripletRule(tau_plus=16.7,
                                                tau_minus=33.7,
                                                tau_x=44,
                                                tau_y=44),
    weight_dependence=p.AdditiveWeightDependence(w_min=0.0,
                                                 w_max=1.0,
                                                 A_plus=0.005,
                                                 A_minus=0.005),
    mad=True)
TrianSpikeON = BuildTrainingSpike(order,1)
FourDirectionTime = BuildTrainingSpike(order,1)
spikeArrayOn = {'spike_times': TrianSpikeON}
ON_pop = sim.Population(prepop_size, sim.SpikeSourceArray,
                        spikeArrayOn, label='inputSpikes_On')
post_pop= sim.Population(postpop_size,sim.IF_curr_exp,
                         cell_params_lif, label='post_1')
#------------------------------------------------#
# STDP and Neuron Network Specification#
#------------------------------------------------#
stdp_model = sim.STDPMechanism(
                timing_dependence=sim.SpikePairRule(tau_plus=15.0,
                                                    tau_minus=25.0
                                                  ,nearest=True),
                weight_dependence=sim.AdditiveWeightDependence(w_min=0,
                                                               w_max=0.5,
                                                               A_plus=0.012,
                                                               A_minus=0.01))
weight_ini = np.random.normal(0.108, 0.003,prepop_size*postpop_size).tolist()
delay_ini = np.random.normal(2, 0.3,prepop_size*postpop_size).tolist()

connectionsOn = sim.Projection(ON_pop, post_pop, sim.AllToAllConnector(
    weights = weight_ini,delays=2),
                               synapse_dynamics=sim.SynapseDynamics(
                                   slow=stdp_model))
#inhibitory between the neurons
connection_I  = sim.Projection(post_pop, post_pop,
                               sim.AllToAllConnector(weights = 0.08,delays=1),
                               target='inhibitory')

post_pop.record()
#post_pop.record_v()
    # Up
    if y > 0:
        add_connection(x, y, x, y - 1, cost_image, conn_list, delay_func,
                       weight_func)

    # Down
    if y < (cost_image.shape[1] - 1):
        add_connection(x, y, x, y + 1, cost_image, conn_list, delay_func,
                       weight_func)

if plastic:
    stdp_model = sim.STDPMechanism(
        timing_dependence=sim.SpikePairRule(tau_plus=50.0, tau_minus=50.0),
        weight_dependence=sim.AdditiveWeightDependence(
            w_min=0.0,
            w_max=instant_spike_weight,
            A_plus=0.000001,
            A_minus=1.0),
        dendritic_delay_fraction=1.0)
    synapse_dynamics = sim.SynapseDynamics(slow=stdp_model)
else:
    synapse_dynamics = None

# Create connector
proj = sim.Projection(neurons,
                      neurons,
                      sim.FromListConnector(conn_list),
                      synapse_dynamics=synapse_dynamics,
                      target="excitatory")

# Stimulate stim neuron