Forward propagation
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(conv2d_layer_type), | intent(inout) | :: | this |
Instance of the 2D convolutional layer |
||
| class(array_type), | intent(in), | dimension(:,:) | :: | input |
Input values |
subroutine forward_conv2d(this, input) !! Forward propagation implicit none ! Arguments class(conv2d_layer_type), intent(inout) :: this !! Instance of the 2D 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 => conv2d(this%pad_layer%output(1,1), this%params(1), & this%stp, this%dil & ) case default ptr => conv2d(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=3, 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_conv2d