---
title: "ClikaRT::nn::Hardtanh"
sidebar_label: "Hardtanh"
description: "Clamps every element to [min_val, max_val]. The module form of ClikaRT::ops::hardtanh, which documents the full contract (shapes, dtypes, errors); construct once, then call it like a function."
---

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

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

**Header:** `ClikaRT/nn/generated/activation.h`  
**Inherits:** [`ClikaRT::nn::Module`](./Module.md)

Clamps every element to \[min\_val, max\_val\]. The module form of [`ClikaRT::ops::hardtanh`](../ops/hardtanh.md#hardtanh), which documents the full contract (shapes, dtypes, errors); construct once, then call it like a function.

## Member functions

### Hardtanh(HardtanhOptions) {#Hardtanh}

<div class="api-signature">

`explicit` **`Hardtanh`**([`HardtanhOptions`](./HardtanhOptions.md) `options` `=` `{}`)

</div>

Constructs the module from [`options`](./Hardtanh.md#options) (every default when omitted).

<div class="api-declared">

Declared in `ClikaRT/nn/generated/activation.h`, line 785

</div>

### Hardtanh(double, double) {#Hardtanh-2}

<div class="api-signature">

`explicit` **`Hardtanh`**(`double` `min_val`, `double` `max_val` `=` `1.0`)

</div>

`Hardtanh(min_val, max_val)`: the positional form of `HardtanhOptions(min_val, max_val)`.

<div class="api-declared">

Declared in `ClikaRT/nn/generated/activation.h`, line 788

</div>

### forward() {#forward}

<div class="api-signature">

[`Tensor`](../Tensor.md) **`forward`**([`Tensor`](../Tensor.md) `input`) `const`

</div>

[`forward_impl`](./Hardtanh.md#forward), unwrapped: raises [`ClikaRT::Error`](../Error.md) on failure.

<div class="api-declared">

Declared in `ClikaRT/nn/generated/activation.h`, line 808

</div>

### operator()() {#operator-call}

<div class="api-signature">

[`Tensor`](../Tensor.md) **`operator()`**([`Tensor`](../Tensor.md) `input`) `const`

</div>

Same as [`forward`](./Hardtanh.md#forward).

<div class="api-declared">

Declared in `ClikaRT/nn/generated/activation.h`, line 812

</div>

### options() {#options}

<div class="api-signature">

`const` [`HardtanhOptions`](./HardtanhOptions.md)`&` **`options`**() `const`

</div>

The settings this module was constructed with.

<div class="api-declared">

Declared in `ClikaRT/nn/generated/activation.h`, line 816

</div>
