2013/uns13/resources: nengo_square.py

File nengo_square.py, 0.8 KB (added by francesco.galluppi, 5 years ago)

Nengo/SpiNNaker square example

Line 
1"""
2square example for nengo/spinnaker
3
4A->B implementing the identity function f(x)=x^2
5
6Results can be viewed using the following command:
7./nengo-cl nengo_spinnaker_interface/viewer_1d.py -b <spinnaker board address> -d 1 -s 2
8"""
9import nef                     
10
11# importing the Nengo/SpiNNakerinterface module
12import nengo_spinnaker_interface.spinn as spinn
13
14def square(x):
15    return(x[0]*x[0])
16
17net=nef.Network('square_spinnaker',quick=True)
18input=net.make_input('input',[0])
19
20A=net.make('A', neurons=100, dimensions=1, max_rate=(100,150),radius=1, intercept=(-.9,.9))
21B=net.make('B', neurons=100, dimensions=1, max_rate=(100,150),radius=1, intercept=(-.9,.9))
22
23net.connect(input,A)
24net.connect(A,B,func=square)
25
26
27s=spinn.SpiNN(net.network)
28s.print_info()
29s.write_to_file('nengo_spinnaker_interface/nengo_values.py')
30
31