hardsigmoid

dragon.nn.hardsigmoid(
  inputs,
  alpha=0.2,
  beta=0.5,
  inplace=False,
  **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., 1., 2.5])
print(dragon.nn.hardsigmoid(x))
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\).
  • inplace (bool, optional, default=False) – Call in-place or return a new tensor.
Returns:

dragon.Tensor – The output tensor.