Skip to content

Commit cfba33b

Browse files
mariosaskofacebook-github-bot
authored andcommitted
Fix the ELU formula in the docs (#43764)
Summary: Fixes #43389. This PR replaces the old ELU formula from the docs that yields wrong results for negative alphas with the new one that fixes the issue and relies on the cases notation which makes the formula more straightforward. Pull Request resolved: #43764 Reviewed By: ailzhang Differential Revision: D23425532 Pulled By: albanD fbshipit-source-id: d0931996e5667897d926ba4fc7a8cc66e8a66837
1 parent 9d4943d commit cfba33b

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

torch/nn/modules/activation.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,10 @@ class ELU(Module):
442442
r"""Applies the element-wise function:
443443
444444
.. math::
445-
\text{ELU}(x) = \max(0,x) + \min(0, \alpha * (\exp(x) - 1))
445+
\text{ELU}(x) = \begin{cases}
446+
x, & \text{ if } x > 0\\
447+
\alpha * (\exp(x) - 1), & \text{ if } x \leq 0
448+
\end{cases}
446449
447450
Args:
448451
alpha: the :math:`\alpha` value for the ELU formulation. Default: 1.0

0 commit comments

Comments
 (0)