oneflow.nn.CELU¶
-
class
oneflow.nn.
CELU
(alpha: float = 1.0, inplace: bool = False)¶ Applies the element-wise function:
\[\begin{split}\text{CELU}(x, \alpha) = \begin{cases} x & \text{ if } x \ge 0 \\ \alpha*(exp(\frac{x}{\alpha})-1) & \text{ otherwise } \\ \end{cases}\end{split}\]- Parameters
alpha – the \(\alpha\) value for the CELU formulation. Default: 1.0
inplace – can optionally do the operation in-place. Default:
False
- Shape:
Input: \((N, *)\) where * means, any number of additional dimensions
Output: \((N, *)\), same shape as the input
For example:
>>> import numpy as np >>> import oneflow as flow >>> x = np.array([-0.5, 0, 0.5]).astype(np.float32) >>> input = flow.Tensor(x) >>> celu = flow.nn.CELU(alpha=0.5) >>> out = celu(input) >>> out tensor([-0.3161, 0.0000, 0.5000], dtype=oneflow.float32)