improve docs of softplus
@@ -58,18 +58,32 @@ class Softplus(function.Function):
def softplus(x, beta=1.0):
- """Elementwise softplus function.
+ """Element-wise softplus function.
- This function is expressed as
- :math:`f(x) = \\frac{1}{\\beta}\\log(1 + \\exp(\\beta x))`,
- where :math:`\\beta` is a parameter.
+ The softplus function is the smooth approximation of ReLU.
+
+ .. math:: f(x)=\\frac{1}{\\beta}\\log(1 + \\exp(\\beta x)),
+
+ where :math:`\\beta` is a parameter. The function becomes curved
+ and akin to ReLU as the :math:`\\beta` is increasing.
Args:
- x (~chainer.Variable): Input variable.
+ x (:class:`~chainer.Variable` or :class:`numpy.ndarray` or \
+ :class:`cupy.ndarray`):
+ Input variable. A :math:`(s_1, s_2, ..., s_N)`-shaped float array.
beta (float): Parameter :math:`\\beta`.
Returns:
- ~chainer.Variable: Output variable.
+ ~chainer.Variable: Output variable. A
+ :math:`(s_1, s_2, ..., s_N)`-shaped float array.
+
+ .. admonition:: Example
+
+ >>> x = np.arange(-2, 3, 2).astype('f')
+ >>> x
+ array([-2., 0., 2.], dtype=float32)
+ >>> F.softplus(x, beta=1.0).data
+ array([ 0.126928 , 0.69314718, 2.12692809], dtype=float32)
"""
return Softplus(beta=beta)(x)
