Get partial derivative of piecewise activation
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(array_type), | intent(inout) | :: | this | |||
| type(array_type), | intent(in) | :: | upstream_grad |
function get_partial_piecewise(this, upstream_grad) result(output) !! Get partial derivative of piecewise activation implicit none class(array_type), intent(inout) :: this type(array_type), intent(in) :: upstream_grad type(array_type) :: output type(array_type), pointer :: ptr ptr => merge( & upstream_grad, & upstream_grad * this%right_operand%val(1,1), & this%left_operand%val.le.-this%right_operand%val(2,1) .or. & this%left_operand%val.ge.this%right_operand%val(2,1) & ) call output%assign_and_deallocate_source(ptr) end function get_partial_piecewise