wkcn opened a new issue #15172: mx.nd.contrib.boolean_mask doesn't support GradientAddition URL: https://github.com/apache/incubator-mxnet/issues/15172 ## Description Hi, there. I found `mx.nd.contrib.boolean_mask` gives a wrong gradient when gradient addition on it. `mx.nd.contrib.boolean_mask` doesn't support Gradient Addition. ## Environment info (Required) ``` ----------Python Info---------- Version : 3.7.3 Compiler : GCC 8.2.1 20181127 Build : ('default', 'Mar 26 2019 21:43:19') Arch : ('64bit', 'ELF') ------------Pip Info----------- Version : 19.0.3 Directory : /usr/lib/python3.7/site-packages/pip ----------MXNet Info----------- Version : 1.5.0 Directory : /home/wkcn/proj/incubator-mxnet/python/mxnet Hashtag not found. Not installed from pre-built package. ----------System Info---------- Platform : Linux-5.1.6-arch1-1-ARCH-x86_64-with-arch system : Linux node : MiraiT release : 5.1.6-arch1-1-ARCH version : #1 SMP PREEMPT Fri May 31 15:17:53 UTC 2019 ``` Package used (Python/R/Scala/Julia): Python ## Build info (Required if built from source) Compiler (gcc/clang/mingw/visual studio): gcc MXNet commit hash: b0be6c50ae686a59c340c56b9c11493a5c84ff72 Build config: `make -j 5 USE_OPENCV=1 USE_BLAS=openblas USE_MKLDNN=0` ## Minimum reproducible example ```python import mxnet as mx a = mx.nd.array([1,2,3,4,5]) a.attach_grad() bi = mx.nd.array([1,1,0,0,0]) ci = mx.nd.array([1,0,0,1,0]) with mx.autograd.record(): b = mx.nd.contrib.boolean_mask(a, bi) c = mx.nd.contrib.boolean_mask(a, ci) su = b.sum() + c.sum() su.backward() print(a.grad) ''' [2.0000000e+00 1.0000000e+00 0.0000000e+00 1.0000000e+00 5.0171812e+04] <NDArray 5 @cpu(0)> ''' ``` ## Steps to reproduce 1. Run the reproduce example 2. The last graident is wrong and random. ## What have you tried to solve it? 1. I read the code, and I found `mx.nd.contrib.boolean_mask` doesn't support GradAdd.
---------------------------------------------------------------- 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
