---
title: "ClikaRT::ops::smooth_l1_loss"
sidebar_label: "smooth_l1_loss"
description: "Smooth-L1 loss: quadratic within beta of zero, L1 beyond it. \\[ \\ell_i = \\begin{cases} \\tfrac{1}{2}(x_i - y_i)^2/\\beta & |x_i - y_i| \\le \\beta \\\\ |x_i - y_i| - \\tfrac{1}{2}\\beta & \\text{otherwise} \\en…"
---

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

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

## smooth\_l1\_loss() {#smooth_l1_loss}

<div class="api-signature">

[`Tensor`](../Tensor.md) **`smooth_l1_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` `beta` `=` `1.0`<br />
)

</div>

Smooth-L1 loss: quadratic within `beta` of zero, L1 beyond it.

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

`beta == 0` degenerates to plain L1.

**Parameters**

- `input`: predictions; float dtype.
- `target`: ground truth; same shape as `input`.
- `reduction`: `None` / `Mean` / `Sum`; default `Mean`.
- `beta`: the L2-to-L1 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 3123

</div>
