print_to_unit_conv Module Subroutine

module subroutine print_to_unit_conv(this, unit)

Print 2D convolutional layer to unit

Arguments

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

Instance of the 2D convolutional layer

integer, intent(in) :: unit

File unit


Source Code

  module subroutine print_to_unit_conv(this, unit)
    !! Print 2D convolutional layer to unit
    implicit none

    ! Arguments
    class(conv_layer_type), intent(in) :: this
    !! Instance of the 2D convolutional layer
    integer, intent(in) :: unit
    !! File unit

    ! Local variables
    integer :: l, i, itmp1, idx
    !! Loop indices
    character(:), allocatable :: padding_type
    !! Padding type
    character(100) :: fmt


    ! Write pad layer if applicable
    !---------------------------------------------------------------------------
    if(allocated(this%pad_layer))then
       call this%pad_layer%print_to_unit(unit)
    end if


    ! Write initial parameters
    !---------------------------------------------------------------------------
    ! write the format string for input shape
    write(fmt,'("(3X,""INPUT_SHAPE ="",",I0,"(1X,I0))")') size(this%input_shape)
    write(unit,fmt) this%input_shape
    write(unit,'(3X,"NUM_FILTERS = ",I0)') this%num_filters
    write(fmt,'("(3X,A,"" ="",",I0,"(1X,I0))")') this%input_rank-1
    if(all(this%knl.eq.this%knl(1)))then
       write(unit,'(3X,"KERNEL_SIZE =",1X,I0)') this%knl(1)
    else
       write(unit,fmt) "KERNEL_SIZE", this%knl
    end if
    if(all(this%stp.eq.this%stp(1)))then
       write(unit,'(3X,"STRIDE =",1X,I0)') this%stp(1)
    else
       write(unit,fmt) "STRIDE", this%stp
    end if
    if(all(this%dil.eq.this%dil(1)))then
       write(unit,'(3X,"DILATION =",1X,I0)') this%dil(1)
    else
       write(unit,fmt) "DILATION", this%dil
    end if

    write(unit,'(3X,"USE_BIAS = ",L1)') this%use_bias
    if(this%activation%name .ne. 'none')then
       call this%activation%print_to_unit(unit)
    end if


    ! Write weights and biases
    !---------------------------------------------------------------------------
    write(unit,'("WEIGHTS")')
    write(unit,'(5(E16.8E2))') this%params(1)%val(:,1)
    write(unit,'(5(E16.8E2))') this%params(2)%val(:,1)
    write(unit,'("END WEIGHTS")')

  end subroutine print_to_unit_conv