Skip to main content

ClikaRT::ops::hardtanh

function

hardtanh()

Tensor hardtanh(
    Tensor x,
    double min_val = -1.0,
    double max_val = 1.0
)

Clamps every element to [min_val, max_val].

hardtanh(x)=clamp(x,  min_val,  max_val)\mathrm{hardtanh}(x) = \mathrm{clamp}(x,\; \mathrm{min\_val},\; \mathrm{max\_val})

Parameters

  • x: the input tensor.
  • min_val: the lower bound. Default -1.0.
  • max_val: the upper bound. Default 1.0.

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 x.

auto y = ClikaRT::ops::hardtanh(x, 0.0, 6.0); // == relu6

Declared in ClikaRT/compute/ops.h, line 869