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 2020/08/05 17:46:22 UTC

[GitHub] [incubator-mxnet] szha commented on issue #18789: [bug] Autograd throws an exception that was not caught in MXNet 1.6

szha commented on issue #18789:
URL: https://github.com/apache/incubator-mxnet/issues/18789#issuecomment-669334140


   ```python
   In [3]: from mxnet import nd
      ...: import mxnet as mx
      ...: x = mx.np.zeros((10,))
      ...: x.attach_grad()
      ...: mx.npx.set_np()
      ...: class Op(mx.autograd.Function):
      ...:     def forward(self, x):
      ...:         out = x + 1
      ...:         return out
      ...:
      ...:     def backward(self, grad):
      ...:         grad_x = grad
      ...:         return grad_x
      ...:
      ...: op = Op()
      ...: with mx.autograd.record():
      ...:     y = op(x)
      ...:     y.sum().backward()
      ...:
      ...: print(x.grad)
   [1. 1. 1. 1. 1. 1. 1. 1. 1. 1.]
   
   In [4]:
   Do you really want to exit ([y]/n)?
   ```


----------------------------------------------------------------
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