get_partial_huber_val Subroutine

pure subroutine get_partial_huber_val(this, upstream_grad, output)

Get partial derivative of huber loss (in-place version)

Arguments

Type IntentOptional Attributes Name
class(array_type), intent(in) :: this
real(kind=real32), intent(in), dimension(:,:) :: upstream_grad
real(kind=real32), intent(out), dimension(:,:) :: output

Source Code

  pure subroutine get_partial_huber_val(this, upstream_grad, output)
    !! Get partial derivative of huber loss (in-place version)
    implicit none
    class(array_type), intent(in) :: this
    real(real32), dimension(:,:), intent(in) :: upstream_grad
    real(real32), dimension(:,:), intent(out) :: output

    where (abs(this%left_operand%val) .le. this%right_operand%val(1,1))
       output = this%left_operand%val
    elsewhere
       output = this%right_operand%val(1,1) * sign(1._real32, this%left_operand%val)
    end where

  end subroutine get_partial_huber_val