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/03/11 20:45:54 UTC

[GitHub] [incubator-mxnet] ThomasDelteil opened a new issue #14391: as_in_context() does not copy the gradient to the new context

ThomasDelteil opened a new issue #14391: as_in_context() does not copy the gradient to the new context
URL: https://github.com/apache/incubator-mxnet/issues/14391
 
 
   I think it should copy the gradient as well automatically?
   
   ```python
   ctx = mx.cpu()
   a = mx.nd.ones((10,10), ctx=ctx)
   a.attach_grad()
   print(a.context)
   print(a.grad.context)
   ctx = mx.gpu()
   a = a.as_in_context(ctx)
   print(a.context)
   print(a.grad.context)
   ```
   
   ```
   cpu(0)
   cpu(0)
   gpu(0)
   ---------------------------------------------------------------------------
   AttributeError                            Traceback (most recent call last)
   <ipython-input-16-deab22190603> in <module>()
         5 ctx = mx.gpu()
         6 a = a.as_in_context(ctx)
   ----> 7 print(a.context, a.grad.context)
   
   AttributeError: 'NoneType' object has no attribute 'context'
   ```

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