Merge two learnable layers via summation
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(learnable_layer_type), | intent(inout) | :: | this |
Instance of the layer |
||
| class(learnable_layer_type), | intent(in) | :: | input |
Instance of a layer |
module subroutine reduce_learnable(this, input) !! Merge two learnable layers via summation implicit none ! Arguments class(learnable_layer_type), intent(inout) :: this !! Instance of the layer class(learnable_layer_type), intent(in) :: input !! Instance of a layer ! Local variables integer :: i !! Loop index if(allocated(this%params).and.allocated(input%params))then if(size(this%params).ne.size(input%params))then call stop_program("reduce_learnable: incompatible parameter sizes") return end if do i = 1, size(this%params,1) this%params(i) = this%params(i) + input%params(i) if(associated(this%params(i)%grad).and.& associated(input%params(i)%grad))then this%params(i)%grad = this%params(i)%grad + & input%params(i)%grad end if end do else call stop_program("reduce_learnable: unallocated parameter arrays") return end if end subroutine reduce_learnable