python将多个3维数组转换成4维数组时,出现(m,)错误。
原因:多个3维数组件存在不同维度的数组,例如大部分3维数组为(n,l,l),而有一个或多个为(m, l, l);且则会出现上述错误。
解决方案:仔细查找3维数组中是否存在不符维度的数组;即个别3维数组与其它3维数组维度不一致。
简化代码:
#num is the number of your 3D data
#3D_data[1] is one of your 3D data
#3D_data[i] is other 3D data
for i in range(num):
if 3D_data[i].shape != 3D_data[1].shape:
print(i,3D_data[i].shape)