谁能解释以下结果为何不同?在一种情况下,我指定了:2
,该值应等效于[0,1]
,但出乎意料的是。
x = np.array([[[1,2,3],[4,5,6],[7,8,9]]])
array([[[1, 2, 3],
[4, 5, 6],
[7, 8, 9]]])
x.shape
(1, 3, 3)
# Works as expected
x[0, :, :2]
array([[1, 2],
[4, 5],
[7, 8]])
# Not as expected, the results got transposed
x[0, :, [0,1]]
array([[1, 4, 7],
[2, 5, 8]])