get_params Module Function

pure module function get_params(this) result(params)

Get the learnable parameters of the layer

This function returns the learnable parameters of the layer as a single array. This has been modified from the neural-fortran library

Arguments

Type IntentOptional Attributes Name
class(learnable_layer_type), intent(in) :: this

Instance of the layer

Return Value real(kind=real32), dimension(this%num_params)

Learnable parameters


Source Code

  pure module function get_params(this) result(params)
    !! Get the learnable parameters of the layer
    !!
    !! This function returns the learnable parameters of the layer
    !! as a single array.
    !! This has been modified from the neural-fortran library
    implicit none

    ! Arguments
    class(learnable_layer_type), intent(in) :: this
    !! Instance of the layer
    real(real32), dimension(this%num_params) :: params
    !! Learnable parameters

    ! Local variables
    integer :: i, start_idx, end_idx
    !! Loop indices

    start_idx = 0
    end_idx = 0
    do i = 1, size(this%params)
       start_idx = end_idx + 1
       end_idx = start_idx + size(this%params(i)%val,1) - 1
       params(start_idx:end_idx) = this%params(i)%val(:,1)
    end do

  end function get_params