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 2017/10/31 23:45:02 UTC

[GitHub] eric-haibin-lin opened a new issue #8491: Inconsistent behavior of sparse elemwise_mul and dense elemwise_mul with nan

eric-haibin-lin opened a new issue #8491: Inconsistent behavior of sparse elemwise_mul and dense elemwise_mul with nan
URL: https://github.com/apache/incubator-mxnet/issues/8491
 
 
   Note: Providing complete information in the most concise form is the best way to get help. This issue template serves as the checklist for essential information to most of the technical issues.
   
   If the issue is non-technical, feel free to present the information in what you believe is the best form.
   
   ## Description
   
   mx.nd.sparse.elemwise_mul(row_sparse, dense) doesn't deal with `nan` the same way as the dense operator does.  @cjolivier01 
   
   ## Environment info
   
   Package used (Python/R/Scala/Julia): python
   (I'm using ...)
   
   ## Build info (Required if built from source)
   
   Compiler (gcc/clang/mingw/visual studio):
   
   MXNet commit hash: 100eb88add1c5a18185226eebde0664cc313f557
   (Paste the output of `git rev-parse HEAD` here.)  
   
   Build config:
   (Paste the content of config.mk, or the build command.)
   
   ## Error Message:
   (Paste the complete error message, including stack trace.)
   
   
   ## Minimum reproducible example
   (If you are using your own code, please provide a short script that reproduces the error. Otherwise, please provide link to the existing example.)
   
   ```
   >>> import scipy.sparse as spsp; import mxnet as mx;
   >>> rsp = mx.nd.sparse.zeros('row_sparse', (2,2))
   >>> nans = mx.nd.ones((2,2)) * np.nan
   >>> mx.nd.sparse.elemwise_mul(rsp.tostype('default'), nans)
   
   [[ nan  nan]
    [ nan  nan]]
   <NDArray 2x2 @cpu(0)>
   
   # This is not consistent with mxnet dense operator
   >>> mx.nd.sparse.elemwise_mul(rsp, nans).asnumpy()
   array([[ 0.,  0.],
          [ 0.,  0.]], dtype=float32)
   
   >>> nans_np = np.ones((2,2)) * np.nan
   >>> csr_scipy = spsp.rand(2,2, format='csr', density=0.5)
   >>> csr_scipy
   <2x2 sparse matrix of type '<type 'numpy.float64'>'
   	with 2 stored elements in Compressed Sparse Row format>
   >>> csr * nans
   array([[ nan,  nan],
          [ nan,  nan]])
   ```
   
   ## Steps to reproduce
   (Paste the commands you ran that produced the error.)
   
   1. run the above script
   2.
   
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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