chainer.functions.rrelu¶
-
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, rx),\]where \(r\) is a random number sampled from a uniform distribution \(U(l, u)\).
Note
The \(r\) corresponds to \(a\) in the original paper (https://arxiv.org/pdf/1505.00853.pdf).
- Parameters
x (
Variable
or N-dimensional array) – 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 (N-dimensional array 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. Ifr
is not specified or set toNone
, anr
will be generated randomly according to the givenl
andu
. Ifr
is specified,l
andu
will be ignored.return_r (bool) – If
True
, the r used for rrelu is returned altogether with the output variable. The returnedr
can latter be reused by passing it tor
argument.
- Returns
When
return_r
isFalse
(default), return the output variable. Otherwise returnes the tuple of the output variable andr
(N-dimensional array). Ther
will be on the same device as the input. A \((s_1, s_2, ..., s_N)\)-shaped float array.- Return type
Example
>>> x = np.array([[-1, 0], [2, -3], [-2, 1]], np.float32) >>> x array([[-1., 0.], [ 2., -3.], [-2., 1.]], dtype=float32) >>> F.rrelu(x).array array([[-0.24850948, 0. ], [ 2. , -0.50844127], [-0.598535 , 1. ]], dtype=float32)