官方代码只给出print(indices, 我print出来有啥用啊,我是需要调用。可以直接 a[indices]? 好像是错误的,正确的该咋用啊?pytorch的bytetensor使用又找不到在mindspore的对应。
互联网上关于这方面使用介绍很少,mindspore要推广应用,这样可不是法子。
import mindspore as ms
>>> from mindspore import ops
>>> x = ms.Tensor([[0.5368, 0.2447, 0.4302, 0.9673],
... [0.4388, 0.6525, 0.4685, 0.1868],
... [0.3563, 0.5152, 0.9675, 0.8230]], dtype=ms.float32)
>>> output = ops.topk(x, 2, dim=1)
>>> print(output)
(Tensor(shape=[3, 2], dtype=Float32, value=
[[ 9.67299998e-01, 5.36800027e-01],
[ 6.52499974e-01, 4.68499988e-01],
[ 9.67499971e-01, 8.23000014e-01]]), Tensor(shape=[3, 2], dtype=Int32, value=
[[3, 0],
[1, 2],
[2, 3]]))
>>> output2 = ops.topk(x, 2, dim=1, largest=False)
>>> print(output2)
(Tensor(shape=[3, 2], dtype=Float32, value=
[[ 2.44700000e-01, 4.30200011e-01],
[ 1.86800003e-01, 4.38800007e-01],
[ 3.56299996e-01, 5.15200019e-01]]), Tensor(shape=[3, 2], dtype=Int32, value=
[[1, 2],
[3, 0],
[0, 1]]))
官方代码只给出print(indices, 我print出来有啥用啊,我是需要调用。可以直接 a[indices]? 好像是错误的,正确的该咋用啊?pytorch的bytetensor使用又找不到在mindspore的对应。
互联网上关于这方面使用介绍很少,mindspore要推广应用,这样可不是法子。