Optimisers
- class stride.optimisation.optimisers.optimiser.LocalOptimiser(variable, **kwargs)[source]
Bases:
ABC
Base class for a local optimiser. It takes the value of the gradient and applies it to the variable.
- Parameters:
variable (Variable) – Variable to which the optimiser refers.
step_size (float or LineSearch, optional) – Step size for the update, defaults to constant 1.
process_grad (callable, optional) – Optional processing function to apply on the gradient prior to applying it.
process_model (callable, optional) – Optional processing function to apply on the model after updating it.
kwargs – Extra parameters to be used by the class.
- dump(*args, **kwargs)[source]
Dump latest version of the optimiser.
- Parameters:
kwargs – Extra parameters to be used by the method
- load(*args, **kwargs)[source]
Load latest version of the optimiser.
- Parameters:
kwargs – Extra parameters to be used by the method
- async pre_process(grad=None, processed_grad=None, **kwargs)[source]
Pre-process the variable gradient before using it to take the step.
- Parameters:
- Returns:
Updated variable.
- Return type:
- reset(**kwargs)[source]
Reset optimiser state along with any stored buffers.
- Parameters:
kwargs – Extra parameters to be used by the method.
- async step(step_size=None, grad=None, processed_grad=None, **kwargs)[source]
Apply the optimiser.
- Parameters:
step_size (float, optional) – Step size to use for this application, defaults to instance step.
grad (Data, optional) – Gradient to use for the step, defaults to variable gradient.
processed_grad (Data, optional) – Processed gradient to use for the step, defaults to processed variable gradient.
kwargs – Extra parameters to be used by the method.
- Returns:
Updated variable.
- Return type:
- class stride.optimisation.optimisers.gradient_descent.GradientDescent(variable, **kwargs)[source]
Bases:
LocalOptimiser
Implementation of a gradient descent update.
- Parameters:
variable (Variable) – Variable to which the optimiser refers.
step_size (float, optional) – Step size for the update, defaults to 1.
kwargs – Extra parameters to be used by the class.