# Learning rules¶

These learning rule types can be used in any place that Nengo learning rule types can be used.

class nengo_extras.learning_rules.AML(d, learning_rate=1.0)[source]

Association matrix learning rule (AML).

Enables one-shot learning without catastrophic forgetting of outer product association matrices.

The cue is provided by the pre-synaptic ensemble. The error signal is split up: error[0] provides a scaling factor to the learning rate. error[1] provides a decay rate (i.e., weights are multiplied with this value in every time step), error[2:] provides the target vector.

The update is given by:

decoders[...] *= error[1]  # decay
decoders[...] += alpha * error[0] * error[2:, None] * np.dot(
pre, base_decoders.T)


where alpha is the learning rate adjusted for dt and base_decoders is the decoder matrix for decoding the identity from the pre-ensemble.

Parameters: d : int Dimensionality of input and output vectors (error signal will be d+2). learning_rate : float, optional Learning rate (increase of dot product similarity per second).
class nengo_extras.learning_rules.DeltaRule(learning_rate=0.0001, pre_tau=0.005, post_fn=None, post_tau=None, post_target='in')[source]

Implementation of the Delta rule.

By default, this implementation pretends the neurons are linear, and thus does not require the derivative of the postsynaptic neuron activation function. The derivative function, or a surrogate function, for the postsynaptic neurons can be provided in post_fn.

The update is given by:

delta W_ij = eta a_j e_i f(u_i)

where e_i is the input error in the postsynaptic neuron space, a_j is the output activity for presynaptic neuron j, u_i is the input for postsynaptic neuron i, and f is a provided function.

Parameters: learning_rate : float A scalar indicating the rate at which weights will be adjusted. pre_tau : float Filter constant on the presynaptic output a_j. post_fn : callable Function f to apply to the postsynaptic inputs u_i. The default of None means the f(u_i) term is omitted. post_tau : float Filter constant on the postsynaptic input u_i. This defaults to None because these should typically be filtered by the connection.