sxjscience opened a new issue #17893: [Bug][Numpy] Wrong gradient of np.where URL: https://github.com/apache/incubator-mxnet/issues/17893 ## Description Example 1: Using np.where(array, array, scalar) ```python import mxnet as mx mx.npx.set_np() a = mx.np.array([1, 0, 1]) b = mx.np.array([2, 3, 4]) b.attach_grad() with mx.autograd.record(): c = mx.np.where(a, b, -1) c.backward() print(b.grad) ``` Output: [0. 1. 0.] Example 2: Using np.where(array, array, array) ```python import mxnet as mx mx.npx.set_np() a = mx.np.array([1, 0, 1]) b = mx.np.array([2, 3, 4]) b.attach_grad() with mx.autograd.record(): c = mx.np.where(a, b, mx.np.array([-1, -1, -1])) c.backward() print(b.grad) ``` Output: [1. 0. 1.] The second one is correct.
---------------------------------------------------------------- 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
