init_gradients_adam Subroutine

private pure subroutine init_gradients_adam(this, num_params)

Initialise gradients for Adam optimiser

Type Bound

adam_optimiser_type

Arguments

Type IntentOptional Attributes Name
class(adam_optimiser_type), intent(inout) :: this

Instance of the Adam optimiser

integer, intent(in) :: num_params

Number of parameters


Source Code

  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