This blog is for notes on how to use the Nengo spiking neuron modeling system

Monday, June 20, 2011

script: combining values in a function

This example takes values from two different networks and multiplies them. Any function can be done in this way - by converting a python function

import nef
net=nef.Network('Test Network')
net.add_to(world)
input1=net.make_input('input1',values=[0])
input2=net.make_input('input2',values=[0])
A=net.make('A',neurons=100,dimensions=1)
B=net.make('B',neurons=100,dimensions=1)
C=net.make('C',neurons=100,dimensions=2)
D=net.make('D',neurons=100,dimensions=1)


net.connect(input1,A)
net.connect(input2,B)


# transform - the brackets are the dimensions of the receiving network
# the values in the brackets are the transpose weights

net.connect(A,C,transform=[[1],[0]])
net.connect(B,C,transform=[[0],[1]])


# define a python function



def multiply(x):
  return x[0]*x[1]




# compute that function here

net.connect(C,D,func=multiply)

No comments:

Post a Comment