Initialise gradients for Adam optimiser
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(adam_optimiser_type), | intent(inout) | :: | this |
Instance of the Adam optimiser |
||
| integer, | intent(in) | :: | num_params |
Number of parameters |
pure subroutine init_gradients_adam(this, num_params) !! Initialise gradients for Adam optimiser implicit none ! Arguments class(adam_optimiser_type), intent(inout) :: this !! Instance of the Adam optimiser integer, intent(in) :: num_params !! Number of parameters ! Initialise gradients if(allocated(this%m)) deallocate(this%m) if(allocated(this%v)) deallocate(this%v) allocate(this%m(num_params), source=0._real32) allocate(this%v(num_params), source=0._real32) end subroutine init_gradients_adam