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 2018/02/23 15:04:47 UTC
[GitHub] dotelos opened a new issue #9872: A bug in an example in the python API document
dotelos opened a new issue #9872: A bug in an example in the python API document
URL: https://github.com/apache/incubator-mxnet/issues/9872
This is an example found in the doc for [mxnet.autograd.Function](https://mxnet.incubator.apache.org/api/python/autograd.html#mxnet.autograd.Function).
```python
class sigmoid(Function):
def forward(self, x):
y = 1 / (1 + mx.nd.exp(-x))
self.save_for_backward(y)
return y
def backward(self, dy):
# backward takes as many inputs as forward's return value,
# and returns as many NDArrays as forward's arguments.
y, = self.saved_tensors
return y * (1-y)
```
The `backward` method should return `dy * y * (1-y)` instead of `y * (1-y)` according to the chain rule.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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