Create Learning Rule

Hi,
I would like to ask if it is possible to create a learning rule other than those available already ?
And IF possible , how to create it?

Hi Omar,

There are two ways to go about this. The first is to design a new learning rule and register it with the builder. You’d follow the same steps as shown here, but doing it for a learning rule instead of a neuron type (so create a learning rule subclass, create an operator that implements your learning rule, create a build function that adds that operator into the simulation, and then register that build function with the builder).

The second approach uses a new feature recently developed in an effort to make it easier to add new learning rules. However, it is so new that you will have to do a bit of work to use it. First you’ll need to make sure you have installed nengo using the developer installation steps. Then switch your branch to the genericrule branch (git checkout genericrule).

Now to add a new learning rule you create a python function that implements your learning rule:

def my_rule(prev, data):
    # prev is the previous value of the thing you want to modify 
    # (e.g., connection weights)
    # data is the input to your learning rule (e.g., error signals)
   ...
   return <change in prev> # (e.g., the change in connection weights)

then you can use your learning rule like this:

rule = nengo.GenericRule(my_rule)
conn = nengo.Connection(..., learning_rule_type=rule) # this is the learned connection

and connect up any inputs you need for your learning rule via nengo.Connection(..., conn.learning_rule) (these inputs are what will show up in data above). You can see the documentation in nengo.learning_rules.GenericRule for more details.

Either technique will allow you to add any learning rule you’d like to Nengo, up to you which approach you want to take.

Thank you so much ,
I tried to reply earlier but have some sort of problem opening the forum.
I will try the second method first and tell you as soon as I get results.