我想将两个数组(a,b)
(每个shape = (30,192,192,1)
)合并为一个(输入),如shape = (30,192,192,2)
。
有没有人可以帮助我?
我的代码如下。
input = np.ndarray((a.shape[0], a.shape[1], a.shape[2],2))
input[:,:,:,0] = a
input[:,:,:,1] = b
但我得到了这个错误。
input[:,:,:,0] = a
ValueError: could not broadcast input array from shape (30,192,192,1) into shape (30,192,192)
如何修复此代码?感谢
答案 0 :(得分:0)
您可以在:
之前重塑a和b数组a=a.reshape((30,192,192))
input[:,:,:,0] = a