---
title: "ClikaRT::ops::hardshrink"
sidebar_label: "hardshrink"
description: "Hard shrinkage: zeroes every element within [-lambd, lambd]. \\[ \\mathrm{hardshrink}(x) = \\begin{cases} x & |x| > \\lambda \\\\ 0 & \\text{otherwise} \\end{cases} \\] input the input tensor."
---

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

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

## hardshrink() {#hardshrink}

<div class="api-signature">

[`Tensor`](../Tensor.md) **`hardshrink`**([`Tensor`](../Tensor.md) `input`, `double` `lambd` `=` `0.5`)

</div>

Hard shrinkage: zeroes every element within `[-lambd, lambd]`.

$$
\mathrm{hardshrink}(x) = \begin{cases} x & |x| > \lambda \\ 0 & \text{otherwise} \end{cases}
$$

**Parameters**

- `input`: the input tensor.
- `lambd`: the shrink threshold (lambda). Default `0.5`.

**Throws**

- `ClikaRT::Error`: when the input's dtype is not served for this operation (the machine-readable reason rides `code_name()`).

**Returns:** a new tensor, same shape and dtype as `input`.

```cpp
auto y = ClikaRT::ops::hardshrink(x, 0.1);
```

<div class="api-declared">

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

</div>
