zleyk22 opened a new issue #17864: An incorrect result generated by 
exec.backward
URL: https://github.com/apache/incubator-mxnet/issues/17864
 
 
   ## Description
   I run the python program below and I get a wrong result (`nan`)
   
   ## To Reproduce
   This is a python program I run:
   ```
   import mxnet as mx
   sym = mx.symbol.prod(data=mx.symbol.Variable("in"), axis=(1))
   exec = sym.bind(mx.cpu(0), {"in":mx.nd.array([[4, 0]])}, 
{"in":mx.nd.array([[9, 9]])})
   
   out = exec.forward()[0]
   print('-- Output:')
   print(exec.outputs)
   exec.backward(mx.nd.ones(out.shape))
   print('-- Gradient:')
   print(exec.grad_dict['in'])
   ```
   I get this output:
   ```
   -- Output:
   [
   [0.]
   <NDArray 1 @cpu(0)>]
   -- Gradient:
   
   [[ 0. nan]]
   <NDArray 1x2 @cpu(0)>
   ```
   But I expected to get this result instead of `[[0. nan]]`:
   ```
   [[0. 4.]]
   ```
   I cannot explain why I get `nan`. It would be helpful if somebody can help 
me with this.
   
   ## Environment
   
   I use MXNet 1.6.0
   and run python 3.7.7 (with ipython 7.13.0)
   

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to