init_flatten Subroutine

private subroutine init_flatten(this, input_shape, verbose)

Initialise flattening layer

Type Bound

flatten_layer_type

Arguments

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

Instance of the flattening layer

integer, intent(in), dimension(:) :: input_shape

Input shape

integer, intent(in), optional :: verbose

Verbosity level


Source Code

  subroutine init_flatten(this, input_shape, verbose)
    !! Initialise flattening layer
    implicit none

    ! Arguments
    class(flatten_layer_type), intent(inout) :: this
    !! Instance of the flattening layer
    integer, dimension(:), intent(in) :: input_shape
    !! Input shape
    integer, optional, intent(in) :: verbose
    !! Verbosity level

    ! Local variables
    integer :: verbose_ = 0
    !! Verbosity level


    !---------------------------------------------------------------------------
    ! Initialise optional arguments
    !---------------------------------------------------------------------------
    if(present(verbose)) verbose_ = verbose


    !---------------------------------------------------------------------------
    ! Initialise input shape
    !---------------------------------------------------------------------------
    this%input_rank = size(input_shape)
    if(.not.allocated(this%input_shape)) call this%set_shape(input_shape)


    !---------------------------------------------------------------------------
    ! Initialise output shape
    !---------------------------------------------------------------------------
    this%num_outputs = product(this%input_shape)
    if(allocated(this%output))then
       if(this%output(1,1)%allocated) call this%output(1,1)%deallocate()
    end if
    allocate(this%output(1,1))
    this%output_shape = [this%num_outputs]


    !---------------------------------------------------------------------------
    ! Allocate arrays
    !---------------------------------------------------------------------------
    if(this%use_graph_input)then
       call stop_program( &
            "Graph input not supported for flatten layer" &
       )
       return
    else
       if(allocated(this%output)) deallocate(this%output)
       allocate( this%output(1,1) )
    end if

  end subroutine init_flatten