2013/uns13/resources: spinn_io_example.py

File spinn_io_example.py, 0.7 KB (added by drasmuss, 5 years ago)

example of new spinn module usage

Line 
1import nef
2import spinn
3
4net = nef.Network("spinn_io_example")
5
6#create 1d population
7input1D = net.make_input("input1D", [0])
8pop1D = net.make("pop1D", 50, 1)
9net.connect(input1D, pop1D)
10    #the spinn module will automatically add an output population
11    #(since the same population can't be both input and output
12    #in spinnaker)
13   
14#create 4d population
15input4D = net.make_input("input4D", [0 for _ in range(4)])
16pop4D = net.make("pop4D", 200, 4)
17net.connect(input4D, pop4D)
18    #the spinn module will automatically split the input/output
19    #up into 2x2D populations, to fit with the 2D Spinnaker
20    #I/O restriction
21   
22net.add_to_nengo()
23   
24s=spinn.SpiNN(net.network)
25s.print_info()
26s.write_to_file('nengo_values.py')