chainer.functions.rrelu(x, l=1. / 8, u=1. / 3, *, r=None, return_r=False)[source]
Randomized Leaky Rectified Liner Unit function.

This function is expressed as

\[f(x)=\max(x, ax),\]

where \(a\) is a random number sampled from a uniform distribution \(U(l, u)\).


  • x (Variable or numpy.ndarray or cupy.ndarray) – Input variable. A \((s_1, s_2, ..., s_N)\)-shaped float array.
  • l (float) – The lower bound of the uniform distribution.
  • u (float) – The upper bound of the uniform distribution.
  • r (numpy.ndarray or None) – The r to be used for rrelu. The shape and dtype must be the same as x[0] and should be on the same device. If r is not specified or set to None, a r will be generated randomly according to the given l and u. If r is specified, l and u will be ignored.
  • return_r (bool) – If True, the r used for rrelu is returned altogether with the output variable. The returned r can latter be reused by passing it to r argument.

When return_r is False (default), return the output variable. Otherwise returnes the tuple of the output variable and r (ndarray). The r will be on the same device as the input. A \((s_1, s_2, ..., s_N)\)-shaped float array.

Return type:

Variable or tuple


>>> x = np.array([[-1, 0], [2, -3], [-2, 1]], 'f')
>>> x
array([[-1.,  0.],
       [ 2., -3.],
       [-2.,  1.]], dtype=float32)
>>> F.rrelu(x).data # doctest: +SKIP
array([[-0.24850948,  0.        ],
       [ 2.        , -0.50844127],
       [-0.598535  ,  1.        ]], dtype=float32)