oneflow.nn.ELU¶
-
class
oneflow.nn.
ELU
(alpha: float = 1.0, inplace: bool = False)¶ - Applies the element-wise function
\(\text{ELU}(x) = \begin{cases}x & \text{ if } x \gt 0 \\\alpha*(exp(x)-1) & \text{ if } x \le 0 \\\end{cases}\)
- Parameters
alpha – the \(\alpha\) value for the ELU 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) >>> elu = flow.nn.ELU() >>> out = elu(input) >>> out tensor([-0.3935, 0.0000, 0.5000], dtype=oneflow.float32)