ml_genn.optimisers package
Optimisers are used for applying gradient updates provided by learning rules to model parameters. They are implemented as GeNN custom updates which access both the variable and the gradients via variable references.
- class ml_genn.optimisers.Adam(alpha=0.001, beta1=0.9, beta2=0.999, epsilon=1e-08)
Bases:
Optimiser
Optimizer that implements the Adam algorithm [Kingma2014]. Adam optimization is a stochastic gradient descent method that is based on adaptive estimation of first-order and second-order moments.
- Parameters:
alpha (float) – Learning rate
beta1 (float) – The exponential decay rate for the 1st moment estimates.
beta2 (float) – The exponential decay rate for the 2nd moment estimates.
epsilon (float) – A small constant for numerical stability. This is the epsilon in Algorithm 1 of the [Kingma2014]
- get_model(gradient_ref, var_ref, zero_gradient, clamp_var=None)
Gets model described by this optimiser
- Parameters:
gradient_ref – GeNN variable reference for model to read gradient from
var_ref – GeNN variable reference to variable to update
zero_gradient (bool) – Should gradient be zeroed at the end of the optimiser custom update? This is typically the behaviour we want when batch size is 1 but, otherwise, gradient_ref points to an intermediate reduced gradient which there is no point in zeroing.
clamp_var (Tuple[float, float] | None) – Should value of variable being updated be clamped after update?
- Return type:
- set_step(genn_cu, step)
Performs optimiser-specific update to compiled optimier object at given training step e.g. recalculating learning rates
- Parameters:
genn_cu – GeNN
CustomUpdate
object optimiser has been compiled intostep – Training step
- class ml_genn.optimisers.Optimiser
Bases:
ABC
Base class for all optimisers
- abstract get_model(gradient_ref, var_ref, zero_gradient, clamp_var=None)
Gets model described by this optimiser
- Parameters:
gradient_ref – GeNN variable reference for model to read gradient from
var_ref – GeNN variable reference to variable to update
zero_gradient (bool) – Should gradient be zeroed at the end of the optimiser custom update? This is typically the behaviour we want when batch size is 1 but, otherwise, gradient_ref points to an intermediate reduced gradient which there is no point in zeroing.
clamp_var (Tuple[float, float] | None) – Should value of variable being updated be clamped after update?
- Return type:
- abstract set_step(genn_cu, step)
Performs optimiser-specific update to compiled optimier object at given training step e.g. recalculating learning rates
- Parameters:
genn_cu – GeNN
CustomUpdate
object optimiser has been compiled intostep (int) – Training step