get_partial_huber Function

function get_partial_huber(this, upstream_grad) result(output)

Get partial derivative of huber loss

Arguments

Type IntentOptional Attributes Name
class(array_type), intent(inout) :: this
type(array_type), intent(in) :: upstream_grad

Return Value type(array_type)


Source Code

  function get_partial_huber(this, upstream_grad) result(output)
    !! Get partial derivative of huber loss
    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( &
         this%left_operand, &
         this%right_operand%val(1,1) * sign(1._real32, this%left_operand), &
         abs(this%left_operand) .le. this%right_operand%val(1,1) &
    )

    call output%assign_and_deallocate_source(ptr)
  end function get_partial_huber