我想连接空的3d numpy数组
#2d array works
xs = np.array([[1,2,3,4,5],[10,20,30,40,50]])
ys = np.array([]).reshape(0,5)
zs = np.vstack([ys, xs])
#3D does not work
bb = np.array([]).reshape(1080, 1920, 0) # empty
ss = np.random.rand(1080, 1920,2) #
dd = np.vstack([bb, ss]) # generate an error
有可能这样做吗?
答案 0 :(得分:1)
沿最后一个轴使用concatenate
来模仿您在2D
数组中看到的行为:
np.concatenate([bb, ss], -1)
>>> np.concatenate([bb, ss], -1).shape
(1080, 1920, 2)