forward_batchnorm1d Subroutine

private subroutine forward_batchnorm1d(this, input)

Forward propagation

Type Bound

batchnorm1d_layer_type

Arguments

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

Instance of the 1D batch normalisation layer

class(array_type), intent(in), dimension(:,:) :: input

Input values


Source Code

  subroutine forward_batchnorm1d(this, input)
    !! Forward propagation
    implicit none

    ! Arguments
    class(batchnorm1d_layer_type), intent(inout) :: this
    !! Instance of the 1D batch normalisation layer
    class(array_type), dimension(:,:), intent(in) :: input
    !! Input values

    ! Local variables
    class(batchnorm_array_type), pointer :: ptr
    ! Pointer array


    select case(this%inference)
    case(.true.)
       ! Do not perform the drop operation

       ptr => batchnorm_inference(input(1,1), this%params(1), &
            this%mean(:), this%variance(:), this%epsilon &
       )

    case default
       ! Perform the drop operation
       ptr => batchnorm( &
            input(1,1), this%params(1),&
            this%momentum, this%mean(:), this%variance(:), this%epsilon &
       )

    end select
    select type(output => this%output(1,1))
    type is(batchnorm_array_type)
       call output%assign_shallow(ptr)
       output%epsilon = ptr%epsilon
       output%mean = ptr%mean
       output%variance = ptr%variance
    end select
    deallocate(ptr)
    this%output(1,1)%is_temporary = .false.

  end subroutine forward_batchnorm1d