chainer.functions.clipped_relu

chainer.functions.clipped_relu(x, z=20.0)[source]

Clipped Rectifier Unit function.

For a clipping value \(z(>0)\), it computes

\[\text{ClippedReLU}(x, z) = \min(\max(0, x), z).\]
Parameters
Returns

Output variable. A \((s_1, s_2, ..., s_n)\)-shaped float array.

Return type

Variable

Example

>>> x = np.random.uniform(-100, 100, (10, 20)).astype(np.float32)
>>> z = 10.0
>>> np.any(x < 0)
True
>>> np.any(x > z)
True
>>> y = F.clipped_relu(x, z=z)
>>> np.any(y.array < 0)
False
>>> np.any(y.array > z)
False