torchact.nn.LeakyReLU

class torchact.nn.LeakyReLU(neg_slope: float = 0.01, inplace: bool = False)[source]

Implementation of LeakyReLU.

\(\text{LeakyReLU}(x) = \max(0, x) + \text{negative_slope} * \min(0, x)\)

Parameters
  • neg_slope (float) – Angle of the negative slope. Default: 1e-2

  • inplace (bool) – In-place operation. Default: False

Examples::
>>> import torch, torchact
>>> m = torchact.nn.LeakyReLU()
>>> input = torch.tensor([1.0, -2.0, 0.0, 3.0])
>>> output = m(input)
>>> print(output)
tensor([ 1.0000, -0.0200,  0.0000,  3.0000])