set_params Module Subroutine

module subroutine set_params(this, params)

Set learnable parameters

Arguments

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

Instance of network

real(kind=real32), intent(in), dimension(this%num_params) :: params

Parameters


Source Code

  module subroutine set_params(this, params)
    !! Set learnable parameters
    implicit none

    ! Arguments
    class(network_type), intent(inout) :: this
    !! Instance of network
    real(real32), dimension(this%num_params), intent(in) :: params
    !! Parameters

    ! Local variables
    integer :: l, i, start_idx, end_idx
    !! Loop index

    start_idx = 0
    end_idx   = 0
    do l = 1, this%num_layers
       select type(current => this%model(l)%layer)
       class is(learnable_layer_type)
          do i = 1, size(current%params)
             start_idx = end_idx + 1
             end_idx = end_idx + size(current%params(i)%val, 1)
             current%params(i)%val(:,1) = params(start_idx:end_idx)
          end do
          !  call current%set_params(params(start_idx:end_idx))
       end select
    end do

  end subroutine set_params