---
title: "ClikaRT::ops::softshrink"
sidebar_label: "softshrink"
description: "Soft thresholding: shrinks every element toward zero by lambd. \\[ \\mathrm{softshrink}(x) = \\mathrm{sign}(x)\\cdot\\max(|x| - \\lambda,\\; 0) \\] input the input tensor. lambd the shrink amount (lambda)."
---

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

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

## softshrink() {#softshrink}

<div class="api-signature">

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

</div>

Soft thresholding: shrinks every element toward zero by `lambd`.

$$
\mathrm{softshrink}(x) = \mathrm{sign}(x)\cdot\max(|x| - \lambda,\; 0)
$$

**Parameters**

- `input`: the input tensor.
- `lambd`: the shrink amount (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::softshrink(x, 0.1);
```

<div class="api-declared">

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

</div>
