Avatar
@tarunon import numpy as np a = np.array([[[[1, 1], [2, 2]], [[3, 3], [4, 4]]], [[[5, 5], [6, 6]], [[7, 7], [8, 8]]]]) a.shape # (2, 2, 2, 2) b = a[0, :, :, 0] b.shape # (2, 2) c = a[0:1, :, :, 0:1] c.shape # (1, 2, 2, 1) (edited)
6:37 AM
N 次元超立方体を考えて、 : の次元は残して、インデックス指定してる次元での断面を求めてるイメージ (edited)
6:38 AM
>>> print(b) [[1 2] [3 4]] >>> print(c) [[[[1] [2]] [[3] [4]]]]