forward_dropblock2d Subroutine

private subroutine forward_dropblock2d(this, input)

Forward propagation

Type Bound

dropblock2d_layer_type

Arguments

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

Instance of the 2D dropblock layer

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

Input values


Source Code

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

    ! Arguments
    class(dropblock2d_layer_type), intent(inout) :: this
    !! Instance of the 2D dropblock layer
    class(array_type), dimension(:,:), intent(in) :: input
    !! Input values

    ! Local variables
    real(real32) :: rtmp1
    !! Temporary variable
    type(array_type), pointer :: ptr
    !! Pointer array


    rtmp1 = 1._real32 - this%rate
    select case(this%inference)
    case(.true.)
       ! Do not perform the drop operation
       ptr => input(1,1) * rtmp1
    case default
       ! Perform the drop operation
       rtmp1 = 1._real32 / rtmp1
       ptr => merge_over_channels( &
            input(1,1), 0._real32, &
            reshape(this%mask, shape = [product(shape(this%mask)), 1]) &
       ) * rtmp1
    end select
    call this%output(1,1)%assign_and_deallocate_source(ptr)
    this%output(1,1)%is_temporary = .false.

  end subroutine forward_dropblock2d