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 2018/07/04 21:42:27 UTC

[GitHub] ThomasDelteil commented on issue #8546: What's the equivalent of np.where()?

ThomasDelteil commented on issue #8546: What's the equivalent of np.where()?
URL: https://github.com/apache/incubator-mxnet/issues/8546#issuecomment-402563089
 
 
   @fallingdust I think unfortunately this usage is not supported. You can use masking, depending on what you want to achieve, you can for example set the values you'd like to ignore to 0 or -1.
   Here is an example where I set the discarded value to -1.
   ```python
   labels = nd.array([-1, 0, 1, 0, 1])
   cls_scores = nd.array([0.1, 0.2, 0.3, 0.4, 0.5])
   cls_scores = nd.where(labels != -1, cls_scores, labels)  
   
   ​
   [-1.   0.2  0.3  0.4  0.5]
   <NDArray 5 @cpu(0)>
   ```
   Or as @zhreshold said, if this code is not in a critical path of your network, you can consider doing your array manipulation in numpy.
   
   @zhreshold could you please close the issue?
   @fallingdust if you would like to follow up, please create a post on https://discuss.mxnet.io and reference this issue. Thanks!
   

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