Skip to main content

ClikaRT::ops::threshold

function

threshold()

Tensor threshold(
    Tensor x,
    double threshold,
    double value
)

Elementwise threshold: keeps values above threshold, replaces the rest with value.

threshold(x)={xx>thresholdvalueotherwise\mathrm{threshold}(x) = \begin{cases} x & x > \mathrm{threshold} \\ \mathrm{value} & \text{otherwise} \end{cases}

Parameters

  • x: the input tensor.
  • threshold: the comparison bound.
  • value: the replacement for elements at or below the bound.

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::threshold(x, 0.0, 0.0); // == relu

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