Threshold#

API#

class warp_nn.modules.activations.Threshold(
*,
threshold: float,
value: float,
requires_grad: bool = True,
)[source]#

Bases: Module

Threshold activation function.

This class computes the element-wise Threshold activation function:

\[\begin{split}\text{Threshold}(x) = \begin{cases} x, & \text{ if } x > \text{threshold}\\ \text{value}, & \text{ otherwise} \end{cases}\end{split}\]

The ONNX ThresholdedRelu operator is equivalent to Threshold(threshold=alpha, value=0).

Parameters:
  • threshold – The value to threshold at.

  • value – The value to replace with.

  • requires_grad – Whether the cached output arrays of the module require gradients.

__call__(
input: array,
) → array[source]#

Forward pass of the activation function.

Parameters:

input – The input array, with up to 3 dimensions.

Returns:

The output array, with same shape as the input array.

Raises:

TypeError – If the input array’s data type or number of dimensions is not supported.

property threshold: float[source]#

The value to threshold at.

property value: float[source]#

The value to replace with.