Skip to content

Commit 598e6c9

Browse files
committed
vogels split example
1 parent 0cc153a commit 598e6c9

2 files changed

Lines changed: 58 additions & 21 deletions

File tree

examples/extra_models_examples/vogels_2011.py

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414
import os
15+
from typing import Optional
1516
import pyNN.spiNNaker as sim
1617
import numpy
1718
import matplotlib.pyplot as pylab
@@ -41,6 +42,12 @@ class Vogels2011(object):
4142
To reproduce the experiment from their paper
4243
"""
4344

45+
def __init__(self, split: bool = False):
46+
if split:
47+
self._n_synapse_cores: Optional[int] = 1
48+
else:
49+
self._n_synapse_cores = None
50+
4451
# Population parameters
4552
MODEL = sim.IF_curr_exp
4653
CELL_PARAMETERS = {
@@ -119,7 +126,8 @@ def _build_network(self, uses_stdp, slow_down):
119126
# Create excitatory and inhibitory populations of neurons
120127
ex_pop = sim.Population(
121128
self.NUM_EXCITATORY, self.MODEL(**self.CELL_PARAMETERS),
122-
label="excit_pop", seed=rng_seed)
129+
label="excit_pop", seed=rng_seed,
130+
n_synapse_cores=self._n_synapse_cores)
123131
in_pop = sim.Population(
124132
self.NUM_INHIBITORY, self.MODEL(**self.CELL_PARAMETERS),
125133
label="inhib_pop", seed=rng_seed)
@@ -343,9 +351,24 @@ def plot(
343351
# Show figures
344352
pylab.show()
345353

354+
def run_script(*, split: bool = False) -> None:
355+
"""
356+
Runs the example script
357+
358+
:param split: If True will split the Populations that receive data
359+
into synapse and neuron cores.
360+
This requires more cores but allows more spikes to be received.
361+
"""
362+
x = Vogels2011(split)
363+
result_weights, static, plastic = x.run(
364+
SLOWDOWN_STATIC, SLOWDOWN_PLASTIC, EXTRACT_WEIGHTS)
365+
if GENERATE_PLOT:
366+
x.plot(result_weights, static, plastic)
367+
368+
# combined binaries [IF_curr_exp_stdp_mad_vogels_2011_additive.aplx]
369+
# split binaries [IF_curr_exp_neuron.aplx,
370+
# synapses_stdp_mad_vogels_2011_additive.aplx]
371+
346372

347-
x = Vogels2011()
348-
result_weights, static, plastic = x.run(
349-
SLOWDOWN_STATIC, SLOWDOWN_PLASTIC, EXTRACT_WEIGHTS)
350-
if GENERATE_PLOT:
351-
x.plot(result_weights, static, plastic)
373+
if __name__ == "__main__":
374+
run_script(split=True)

integration_tests/test_scripts.py

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,15 @@ def test_examples_external_devices_examples_live_examples_balanced_random_live_r
9696
def test_examples_external_devices_examples_pushbot_spinnaker_link_example(self):
9797
self.check_script("examples/external_devices_examples/pushbot_spinnaker_link_example.py")
9898

99-
def test_examples_if_curr_alpha(self):
100-
self.check_script("examples/if_curr_alpha.py")
99+
def test_examples_if_curr_alpha_combined(self):
100+
from examples.if_curr_alpha import run_script
101+
run_script(split=False)
102+
self.check_binaries_used(["IF_curr_alpha.aplx"])
103+
104+
def test_examples_if_curr_alpha_split(self):
105+
from examples.if_curr_alpha import run_script
106+
run_script(split=True)
107+
self.check_binaries_used(["IF_curr_alpha_neuron.aplx", "synapses.aplx"])
101108

102109
def test_examples_stdp_example_izk(self):
103110
self.check_script("examples/stdp_example_izk.py")
@@ -150,19 +157,6 @@ def test_examples_stdp_example_get_plastic_params(self):
150157
def test_examples_extra_models_examples_LGN_Izhikevich(self):
151158
self.check_script("examples/extra_models_examples/LGN_Izhikevich.py")
152159

153-
def test_examples_extra_models_examples_vogel_2011_vogels_2011_live_combined(self):
154-
from examples.extra_models_examples.vogel_2011.vogels_2011_live import run_script
155-
run_script(split=False)
156-
self.check_binaries_used(["IF_curr_exp_stdp_mad_vogels_2011_additive"])
157-
158-
def test_examples_extra_models_examples_vogel_2011_vogels_2011_live_split(self):
159-
from examples.extra_models_examples.vogel_2011.vogels_2011_live import run_script
160-
run_script(split=True)
161-
self.check_binaries_used(["synapses_stdp_mad_vogels_2011_additive"])
162-
163-
# Not testing file due to: Unhandled main
164-
# examples/extra_models_examples/vogel_2011/vogels_2011.py
165-
166160
def test_examples_extra_models_examples_stdp_associative_memory(self):
167161
self.check_script("examples/extra_models_examples/stdp_associative_memory.py")
168162

@@ -196,6 +190,26 @@ def test_examples_extra_models_examples_IF_curr_exp_sEMD_split(self):
196190
def test_examples_extra_models_examples_IF_curr_delta(self):
197191
self.check_script("examples/extra_models_examples/IF_curr_delta.py")
198192

193+
def test_examples_extra_models_examples_vogels_2011_live_combined(self):
194+
from examples.extra_models_examples.vogels_2011_live import run_script
195+
run_script(split=False)
196+
self.check_binaries_used(["IF_curr_exp_stdp_mad_vogels_2011_additive"])
197+
198+
def test_examples_extra_models_examples_vogels_2011_live_split(self):
199+
from examples.extra_models_examples.vogels_2011_live import run_script
200+
run_script(split=True)
201+
self.check_binaries_used(["synapses_stdp_mad_vogels_2011_additive"])
202+
203+
def test_examples_extra_models_examples_vogels_2011_combined(self):
204+
from examples.extra_models_examples.vogels_2011 import run_script
205+
run_script(split=False)
206+
self.check_binaries_used(["IF_curr_exp_stdp_mad_vogels_2011_additive.aplx"])
207+
208+
def test_examples_extra_models_examples_vogels_2011_split(self):
209+
from examples.extra_models_examples.vogels_2011 import run_script
210+
run_script(split=True)
211+
self.check_binaries_used(["IF_curr_exp_neuron.aplx", "synapses_stdp_mad_vogels_2011_additive.aplx"])
212+
199213
def test_examples_extra_models_examples_stdp_example_izk_cond(self):
200214
self.check_script("examples/extra_models_examples/stdp_example_izk_cond.py")
201215

0 commit comments

Comments
 (0)