Squaring the InputΒΆ

Purpose: This demo shows how to construct a network that squares the value encoded in a first population in the output of a second population.

Comments: This is a simple nonlinear function being decoded in the connection weights between the cells. Previous demos are linear decodings.

Usage: Grab the slider control and move it up and down to see the effects of increasing or decreasing input. Notice that the output value does not go negative even for negative inputs. Dragging the input slowly from -1 to 1 will approximately trace a quadratic curve in the output.

Output: See the screen capture below

import nef

net=nef.Network('Squaring') #Create the network object

net.make_input('input',[0]) #Create a controllable input function 
                            #with a starting value of 0
net.make('A',100,1) #Make a population with 100 neurons, 1 dimension
net.make('B',100,1,storage_code='B') #Make a population with 
                                                #100 neurons, 1 dimensions
net.connect('input','A') #Connect the input to A
net.connect('A','B',func=lambda x: x[0]*x[0]) #Connect A and B with the 
                                          #defined function approximated 
                                          #in that connection

Nengo User Manual

Table Of Contents

This Page