Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

mx.nd.contrib.boolean_mask doesn't support GradientAddition #15172

Closed
wkcn opened this issue Jun 7, 2019 · 2 comments
Closed

mx.nd.contrib.boolean_mask doesn't support GradientAddition #15172

wkcn opened this issue Jun 7, 2019 · 2 comments
Labels

Comments

@wkcn
Copy link
Member

wkcn commented Jun 7, 2019

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

Build config:
make -j 5 USE_OPENCV=1 USE_BLAS=openblas USE_MKLDNN=0

Minimum reproducible example

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 gradient 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.
@mxnet-label-bot
Copy link
Contributor

Hey, this is the MXNet Label Bot.
Thank you for submitting the issue! I will try and suggest some labels so that the appropriate MXNet community members can help resolve it.
Here are my recommended labels: Feature

@wkcn
Copy link
Member Author

wkcn commented Jun 9, 2019

The issue has been fixed. Close it.

@wkcn wkcn closed this as completed Jun 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants