numpy-如何通过多维索引选择元素?

时间:2019-12-01 03:41:34

标签: numpy-indexing

numpy代码:

import numpy as np
a = np.random.randn(3000,300,13)
print(a[[0],:,[0,1]].shape)

结果:

(2, 300)

但是我想要的是:

(1,300,2)

另一个代码:

import numpy as np
a = np.random.randn(3000,300,13)
print(a[[0,1,2],:,[0,1]].shape)

结果:

IndexError: shape mismatch: indexing arrays could not be broadcast together with shapes (3,) (2,) 

但是我想要的是:

(3,300,2)

0 个答案:

没有答案