Apply gradients to parameters to minimise loss using Adagrad optimiser
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(adagrad_optimiser_type), | intent(inout) | :: | this |
Instance of the Adagrad optimiser |
||
| real(kind=real32), | intent(inout), | dimension(:) | :: | param |
Parameters |
|
| real(kind=real32), | intent(inout), | dimension(:) | :: | gradient |
Gradients |
pure subroutine minimise_adagrad(this, param, gradient) !! Apply gradients to parameters to minimise loss using Adagrad optimiser implicit none ! Arguments class(adagrad_optimiser_type), intent(inout) :: this !! Instance of the Adagrad optimiser real(real32), dimension(:), intent(inout) :: param !! Parameters real(real32), dimension(:), intent(inout) :: gradient !! Gradients real(real32) :: learning_rate !! Learning rate ! Decay learning rate and update iteration learning_rate = this%lr_decay%get_lr(this%learning_rate, this%iter) ! Apply regularisation if(this%regularisation) & call this%regulariser%regularise( param, gradient, learning_rate ) this%sum_squares = this%sum_squares + gradient ** 2._real32 ! Update parameters param = param - learning_rate * gradient / & (sqrt(this%sum_squares + this%epsilon)) end subroutine minimise_adagrad