hardsigmoid

dragon.nn.hardsigmoid(
  inputs,
  alpha=0.2,
  beta=0.5,
  **kwargs
)[source]

Apply the hard sigmoid function.

The HardSigmoid function is defined as:

\[\text{HardSigmoid}(x) = \max(0, \min(1, \alpha * x + \beta)) \]

Examples:

x = dragon.constant([-2.5, -1.0, 0.0, 1.0, 2.5])
print(dragon.nn.hardsigmoid(x, inplace=False))
Parameters:
  • inputs (dragon.Tensor) – The input tensor.
  • alpha (float, optional, default=0.2) – The value to \(\alpha\).
  • beta (float, optional, default=0.5) – The value to \(\beta\).
Returns:

dragon.Tensor – The output tensor.