eric-haibin-lin opened a new issue #9980: [Feature Request] broadcast_mul(csr, 
dense) 
URL: https://github.com/apache/incubator-mxnet/issues/9980
 
 
   Let's say we have a MxN CSR matrix, it's quite common to normalize the CSR 
matrix `A` by a length M vector or a length N vector `B`.
    
   However, MXNet doesn't support broadcast_mul(csr, dense) = csr. In scipy, 
you have to do normalization with the following walk-around with a dot product:
   
   ```python
       A = <some scipy csr metrics>
       B = np.asarray(A.sum(axis=1)).squeeze()
    
       row_scaling = scipy.sparse.spdiags(1/B, 0, dim, dim)
       normalized_A = row_scaling * A
   ```
   
   What we can do in MXNet is to directly support broadcast_mul(csr, dense) = 
csr. Note that an efficient implementation only looks up non-zeros in the csr 
matrix and find the corresponding element in the dense right-hand-side. This 
means that if the dense matrix has any `Nan` element, we are ignoring it during 
the computation (we are already doing this in `sparse.dot`). 
   
   For a complete implementation, both 1-D and 2-D dense ndarray as rhs should 
be implemented. 

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to