init_base Subroutine

private subroutine init_base(this, num_params, regulariser, clip_dict)

Initialise base optimiser

Type Bound

base_optimiser_type

Arguments

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

Instance of the base optimiser

integer, intent(in) :: num_params

Number of parameters

class(base_regulariser_type), intent(in), optional :: regulariser

Regularisation method

type(clip_type), intent(in), optional :: clip_dict

Clipping dictionary


Source Code

  subroutine init_base(this, num_params, regulariser, clip_dict)
    !! Initialise base optimiser
    implicit none

    ! Arguments
    class(base_optimiser_type), intent(inout) :: this
    !! Instance of the base optimiser
    integer, intent(in) :: num_params
    !! Number of parameters
    class(base_regulariser_type), optional, intent(in) :: regulariser
    !! Regularisation method
    type(clip_type), optional, intent(in) :: clip_dict
    !! Clipping dictionary


    ! Apply regularisation
    if(present(regulariser))then
       this%regularisation = .true.
       if(allocated(this%regulariser)) deallocate(this%regulariser)
       allocate(this%regulariser, source = regulariser)
    end if

    ! Apply clipping
    if(present(clip_dict)) this%clip_dict = clip_dict

    ! Initialise gradients
    call this%init_gradients(num_params)
  end subroutine init_base