---
title: "ClikaRT::ops::huber_loss"
sidebar_label: "huber_loss"
description: "Huber loss: quadratic near zero, linear past the delta knee. \\[ \\ell_i = \\begin{cases} \\tfrac{1}{2}(x_i - y_i)^2 & |x_i - y_i| \\le \\delta \\\\ \\delta\\,(|x_i - y_i| - \\tfrac{1}{2}\\delta) & \\text{otherwis…"
---

<!-- Generated by tools/doxygen2mdx from Doxygen XML. Do not edit. -->

<span class="api-kind api-kind--function">function</span>

## huber\_loss() {#huber_loss}

<div class="api-signature">

[`Tensor`](../Tensor.md) **`huber_loss`**(<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`Tensor`](../Tensor.md) `input`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`Tensor`](../Tensor.md) `target`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`Reduction`](./index.md#Reduction) `reduction` `=` [`Reduction::Mean`](./index.md#Reduction),<br />
&nbsp;&nbsp;&nbsp;&nbsp;`double` `delta` `=` `1.0`<br />
)

</div>

Huber loss: quadratic near zero, linear past the `delta` knee.

$$
\ell_i = \begin{cases}
  \tfrac{1}{2}(x_i - y_i)^2 & |x_i - y_i| \le \delta
  \\ \delta\,(|x_i - y_i| - \tfrac{1}{2}\delta) & \text{otherwise}
\end{cases}
$$

**Parameters**

- `input`: predictions; float dtype.
- `target`: ground truth; same shape as `input`.
- `reduction`: `None` / `Mean` / `Sum`; default `Mean`.
- `delta`: the quadratic-to-linear knee; default 1.0.

**Returns:** the loss (0-D under `Mean`/`Sum`).

**Throws**

- `ClikaRT::Error`: (`INVALID_ARGUMENT`) on an input/target shape mismatch.

<div class="api-declared">

Declared in `ClikaRT/compute/ops.h`, line 3043

</div>
