RReLU — PyTorch 2.7 documentation (original) (raw)

class torch.nn.RReLU(lower=0.125, upper=0.3333333333333333, inplace=False)[source][source]

Applies the randomized leaky rectified linear unit function, element-wise.

Method described in the paper:Empirical Evaluation of Rectified Activations in Convolutional Network.

The function is defined as:

RReLU(x)={xif x≥0ax otherwise \text{RReLU}(x) = \begin{cases} x & \text{if } x \geq 0 \\ ax & \text{ otherwise } \end{cases}

where aa is randomly sampled from uniform distributionU(lower,upper)\mathcal{U}(\text{lower}, \text{upper}) during training while during evaluation aa is fixed with a=lower+upper2a = \frac{\text{lower} + \text{upper}}{2}.

Parameters

Shape:

../_images/RReLU.png

Examples:

m = nn.RReLU(0.1, 0.3) input = torch.randn(2) output = m(input)