hardswish

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

Apply the hard swish function. [Howard et.al, 2019].

The HardSwish function is defined as:

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

Examples:

x = dragon.constant([-2.5, -1.0, 0.0, 1.0, 2.5])
print(dragon.nn.hardswish(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\).
Returns:

dragon.Tensor – The output tensor.