get_num_params Module Function

pure module function get_num_params(this) result(num_params)

Get the number of learnable parameters in the network

Arguments

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

Instance of network

Return Value integer

Number of parameters


Source Code

  pure module function get_num_params(this) result(num_params)
    !! Get the number of learnable parameters in the network
    implicit none

    ! Arguments
    class(network_type), intent(in) :: this
    !! Instance of network
    integer :: num_params
    !! Number of parameters

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

    num_params = 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)
             num_params = num_params + size(current%params(i)%val, 1)
          end do
       end select
    end do

  end function get_num_params