We now turn to creating nonlinear transformations in Nengo. The main idea here is that instead of using the X origin, we will create a new origin that estimates some arbitrary function of X. This will allow us to estimate any desired function.
- The accuracy of this estimate will, of course, be dependent on the properties of the neurons.
For one-dimensional ensembles, we can calculate various 1-dimensional functions:
To perform a non-linear operation, we need to define a new origin
- The X origin just uses .
- Create a new ensemble and a function input. The ensemble should be one-dimensional with 100 neurons and a radius of 1. Use a Constant Function input set to 0.5.
- Create a termination on the ensemble and connect the function input to it
- Now create a new origin that will estimate the square of the value.
- Drag the Origin icon from the sidebar onto the ensemble
- Set the name to square
- Click on Set Functions
- Select User-defined Function and press Set
- For the Expression, enter x0*x0. We refer to the value as x0 because when we extend this to multiple dimensions, we will refer to them as x0, x1, x2, and so on.
- Press OK, OK, and OK.
- You can now generate a plot that shows how good the ensemble is at calculating the non-linearity. Right-click on the ensemble and select Plot->Plot distortion:square.
Since X (the value being represented by an ensemble) can also be multidimensional, we can also calculate these sorts of functions
To begin, we create two ensembles and two function inputs. These will represent the two values we wish to multiply together.
- The ensembles should be one-dimensional, use 100 neurons and have a radius of 10 (so they can represent values between -10 and 10)
- The two function inputs should be constants set to 8 and 5
- The terminations you create to connect them should have time constants of 0.01 (AMPA)
Now create a two-dimensional neural ensemble with a radius of 15 called Combined
- Since it needs to represent multiple values, we increase the number of neurons it contains to 200
Add two terminations to Combined
- For each one, the input dimensions are 1
- For the first one, use Set Weights to make the transformation be [1 0]
- For the second one, use Set Weights to make the transformation be [0 1]
Connect the two other ensembles to the Combined one
Now we need to create a new origin that will estimate the product between the two values stored in the combined ensemble.
- Drag the Origin icon onto the Combined ensemble
- Set the name to product
- Set Output dimensions to 1
We can combine these two approaches in order to compute more complex funxtions, such as
- Drag an Origin onto the ensemble representing the first of the two values.
- Give it the name “square”, set its output dimensions to 1, and press Set Functions.
- As before, select the User-defined Function and press Set.
- Set the Expression to be “x0*x0”.
- Press OK, OK, and OK to finish creating the origin.
- This new origin will calculate the square of the value represented by this ensemble.
- If you connect this new origin to the Combined ensemble instead of the standard X origin, the network will calculate instead of . [Note: To remove the X origin projection, drag it away from the Combined population. Right-click the end of the line and select ‘Remove’ to delete the projection altogether.]