Softplus#

API#

class warp_nn.modules.activations.Softplus(
*,
beta: float = 1.0,
threshold: float = 20.0,
requires_grad: bool = True,
)[source]#

Bases: Module

Softplus activation function.

This class computes the element-wise Softplus activation function:

\[\text{Softplus}(x) = \frac{1}{\beta} \log(1 + e^{\beta x})\]

For numerical stability, the implementation reverts to the linear function when \(\beta \, x > \text{threshold}\).

Parameters:
  • beta – The beta value for the Softplus function. It must be non-zero.

  • threshold – When \(\beta \, x\) exceeds this value, the output reverts to the linear function.

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

Raises:

ValueError – If beta is zero.

__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 beta[source]#

The beta value for the Softplus function.

property threshold[source]#

The threshold value above which the Softplus function reverts to the linear function.