我有以下numpy数组维度:[64, 897]. 该数据是在每次实验后生成的。我总共有 8 个科目,每个科目我做了 6 次实验。因此,我希望最后有一个以下大小的 4 维数组:[8, 6, 64, 897].我怎样才能numpy在python中实现这一点。任何帮助深表感谢!!
1 回答

白猪掌柜的
TA贡献1893条经验 获得超10个赞
根据@rafaelc,这是解决方案:
total_slices = []
for i in range(8):
slices_ = []
for j in range(6):
slices = result_of_experiment() # This will return an np.array of shape: [64, 8970
slices_.append(slices)
slices = np.stack(slices_, axis=0)
print("slices.shape", slices.shape)
total_slices.append(slices)
total_slices = np.stack(total_slices, axis=0)
print("total_slices.shape", total_slices.shape)
添加回答
举报
0/150
提交
取消