Performing MultiplicationΒΆ

Purpose: This demo shows how to construct a network that multiplies two inputs.

Comments: This can be thought of as a combination of the combining demo and the squaring demo. Essentially, we project both inputs independently into a 2D space, and then decode a nonlinear transformation of that space (the product of the first and second vector elements).

Multiplication is extremely powerful. Following the simple usage instructions below suggests how you can exploit it to do gating of information into a population, as well as radically change the response of a neuron to its input (i.e. completely invert its ‘tuning’ to one input dimension by manipulating the other).

Usage: Grab the slider controls and move them up and down to see the effects of increasing or decreasing input. The output is the product of the inputs. To see this quickly, leave one at zero and move the other. Or, set one input at a negative value and watch the output slope go down as you move the other input up.

Output: See the screen capture below

import nef

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

net.make_input('input A',[8]) #Create a controllable input function 
                                    #with a starting value of 8
net.make_input('input B',[5]) #Create a controllable input function 
                                    #with a starting value of 5
net.make('A',100,1,radius=10) #Make a population with 100 neurons,
                                           #1 dimensions, a radius of 10
                                           #(default is 1)
net.make('B',100,1,radius=10) #Make a population with 100 neurons, 1 dimensions, a
                      #radius of 10 (default is 1)                    
                #Make a population with 225 neurons, 2 dimensions, and set a 
                #larger radius (so 10,10 input still fits within the circle 
                #of that radius)
net.make('D',100,1,radius=100) #Make a population with 100 neurons, 1 dimensions, a 
                      #radius of 10 (default is 1)
net.connect('input A','A') #Connect all the relevant objects
net.connect('input B','B')
net.connect('A','Combined',transform=[1,0]) #Connect with the given 1x2D mapping matrix

def product(x):
    return x[0]*x[1]
net.connect('Combined','D',func=product) #Create the output connection mapping the 
                              #1D function 'product'

Nengo User Manual

Table Of Contents

This Page