init_gradients_sgd Subroutine

private pure subroutine init_gradients_sgd(this, num_params)

Initialise gradients for SGD optimiser

Type Bound

sgd_optimiser_type

Arguments

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

Instance of the SGD optimiser

integer, intent(in) :: num_params

Number of parameters


Source Code

  pure subroutine init_gradients_sgd(this, num_params)
    !! Initialise gradients for SGD optimiser
    implicit none

    ! Arguments
    class(sgd_optimiser_type), intent(inout) :: this
    !! Instance of the SGD optimiser
    integer, intent(in) :: num_params
    !! Number of parameters


    ! Initialise gradients
    if(allocated(this%velocity)) deallocate(this%velocity)
    allocate(this%velocity(num_params), source=0._real32)
  end subroutine init_gradients_sgd