-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathstdp_split.py
More file actions
executable file
·86 lines (68 loc) · 3.07 KB
/
stdp_split.py
File metadata and controls
executable file
·86 lines (68 loc) · 3.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# Copyright (c) 2021 The University of Manchester
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import pyNN.utility.plotting as plot
import matplotlib.pyplot as plt
import pyNN.spiNNaker as sim
n_neurons = 192
simtime = 5000
sim.setup(timestep=1.0)
sim.set_number_of_neurons_per_core(sim.IF_curr_exp, 64)
sim.set_number_of_synapse_cores(sim.IF_curr_exp, 1)
sim.set_allow_delay_extensions(sim.IF_curr_exp, False)
pre_pop = sim.Population(n_neurons, sim.IF_curr_exp(), label="Pre")
post_pop = sim.Population(n_neurons, sim.IF_curr_exp(), label="Post")
pre_noise = sim.Population(
n_neurons, sim.SpikeSourcePoisson(rate=10.0), label="Noise_Pre")
post_noise = sim.Population(
n_neurons, sim.SpikeSourcePoisson(rate=10.0), label="Noise_Post")
pre_pop.record("spikes")
post_pop.record("spikes")
training = sim.Population(
n_neurons,
sim.SpikeSourcePoisson(rate=10.0, start=1500.0, duration=1500.0),
label="Training")
sim.Projection(pre_noise, pre_pop, sim.OneToOneConnector(),
synapse_type=sim.StaticSynapse(weight=2.0))
sim.Projection(post_noise, post_pop, sim.OneToOneConnector(),
synapse_type=sim.StaticSynapse(weight=2.0))
sim.Projection(training, pre_pop, sim.OneToOneConnector(),
synapse_type=sim.StaticSynapse(weight=5.0, delay=1.0))
sim.Projection(training, post_pop, sim.OneToOneConnector(),
synapse_type=sim.StaticSynapse(weight=5.0, delay=10.0))
timing_rule = sim.SpikePairRule(tau_plus=20.0, tau_minus=20.0,
A_plus=0.5, A_minus=0.5)
weight_rule = sim.AdditiveWeightDependence(w_max=5.0, w_min=0.0)
stdp_model = sim.STDPMechanism(timing_dependence=timing_rule,
weight_dependence=weight_rule,
weight=0.0, delay=5.0)
stdp_projection = sim.Projection(pre_pop, post_pop, sim.OneToOneConnector(),
# sim.StaticSynapse(0, 5.0))
synapse_type=stdp_model)
sim.run(simtime)
pre_neo = pre_pop.get_data(variables=["spikes"])
pre_spikes = pre_neo.segments[0].spiketrains
post_neo = post_pop.get_data(variables=["spikes"])
post_spikes = post_neo.segments[0].spiketrains
print(stdp_projection.get('weight', format="list"))
sim.end()
line_properties = [{'color': 'red', 'markersize': 5},
{'color': 'blue', 'markersize': 2}]
plot.Figure(
# plot spikes
plot.Panel(pre_spikes, post_spikes, yticks=True, xlim=(0, simtime),
line_properties=line_properties),
title="STDP Network Example",
annotations=f"Simulated with {sim.name()}"
)
plt.show()