You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by GitBox <gi...@apache.org> on 2019/04/12 06:37:04 UTC
[GitHub] [incubator-mxnet] fierceX commented on a change in pull request
#14673: [BUGFIX] fix ELU function will appear nan when calculating the
gradient
fierceX commented on a change in pull request #14673: [BUGFIX] fix ELU function will appear nan when calculating the gradient
URL: https://github.com/apache/incubator-mxnet/pull/14673#discussion_r274775676
##########
File path: python/mxnet/gluon/nn/activations.py
##########
@@ -158,7 +158,8 @@ def __init__(self, alpha=1.0, **kwargs):
self._alpha = alpha
def hybrid_forward(self, F, x):
- return F.where(x > 0, x, self._alpha * (F.exp(x) - 1.0))
+ _x = F.where(x < 0, x, F.zeros_like(x))
+ return F.where(x > 0, x, self._alpha * (F.exp(_x) - 1.0))
Review comment:
This bug does not affect the forward calculation, but occurs when the gradient is calculated backwards.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services