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

Monday, June 20, 2011

Two functions

a net can compute more than one function, here is an example:

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])
input3=net.make_input('input3',values=[0])

A=net.make('A',neurons=100,dimensions=1)
B=net.make('B',neurons=100,dimensions=1)
F=net.make('F',neurons=100,dimensions=1)
C=net.make('C',neurons=100,dimensions=3)
D=net.make('D',neurons=100,dimensions=2)


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

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


def multiply(x):
  return x[0]*x[1],x[0]*x[2]    # just add more functions
                                              # the dimension of the recieving network must match

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

No comments:

Post a Comment