How to use argsort to zero out a matrix


#1

Hello,

I am wondering about how to ‘zero’ out an NDArray based on argsort.
What I am trying to do is the equivalent of numpy code:

X[np.argsort(X,axis=1)[:,a:]] = 0 where a is an int in the range of size of X

Is there a clear and still fast (with no type conversion) way to do it?
Thanks.
Marco


#2

I realized that it has been fixed in mxnet 1.0.0.
Just use

X[nd.argsort(X,axis=1)[:,a:]] = 0

Marco