Ndarray problem

below code does not work in mxnet, but numpy, pytorch does
why no on mxnet?

import mxnet as mx
array = mx.nd.arange(100).reshape(10,10)
select = array > 50
array[select]

It does not work because select is just an array of bool variables. If select is an array of integers than the code will work fine e.g.

inds = np.where(array.asnumpy() > 50)
array[inds]

Here is a great tutorial about basic and avanced indexing of MXNet ndarrays https://mxnet.incubator.apache.org/versions/master/tutorials/basic/ndarray_indexing.html

1 Like