forward_conv3d Subroutine

private subroutine forward_conv3d(this, input)

Forward propagation

Type Bound

conv3d_layer_type

Arguments

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

Instance of the 3D convolutional layer

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

Input values


Source Code

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

    ! Arguments
    class(conv3d_layer_type), intent(inout) :: this
    !! Instance of the 3D convolutional layer
    class(array_type), dimension(:,:), intent(in) :: input
    !! Input values

    ! Local variables
    type(array_type), pointer :: ptr
    !! Pointer array


    ! Generate outputs from weights, biases, and inputs
    !---------------------------------------------------------------------------
    select case(allocated(this%pad_layer))
    case(.true.)
       call this%pad_layer%forward(input)
       ptr => conv3d(this%pad_layer%output(1,1), this%params(1), &
            this%stp, this%dil &
       )
    case default
       ptr => conv3d(input(1,1), this%params(1), this%stp, this%dil)
    end select
    call this%z(1)%zero_grad()
    call this%z(1)%assign_and_deallocate_source(ptr)
    this%z(1)%is_temporary = .false.
    ptr => add_bias(this%z(1), this%params(2), dim=4, dim_act_on_shape=.true.)

    ! Apply activation function to activation
    !---------------------------------------------------------------------------
    call this%output(1,1)%zero_grad()
    if(trim(this%activation%name) .eq. "none")then
       call this%output(1,1)%assign_and_deallocate_source(ptr)
    else
       call this%z(2)%zero_grad()
       call this%z(2)%assign_and_deallocate_source(ptr)
       this%z(2)%is_temporary = .false.
       ptr => this%activation%apply(this%z(2))
       call this%output(1,1)%assign_and_deallocate_source(ptr)
    end if
    this%output(1,1)%is_temporary = .false.

  end subroutine forward_conv3d