我有以下numpy数组,我想使用numpy.hstack(())连接
dim(train_frames1)=(2000, 1, 224, 224)
dim(train_frames2)(1000, 1, 224, 224)
dim(train_frames3)=(2000, 1, 224, 224)
dim(train_frames4)=(2000, 1, 224, 224)
dim(train_frames5)=(2000, 1, 224, 224)
dim(train_frames6)=(586, 1, 224, 224)
我做了以下事情:
import numpy as np
train=np.hstack((train_frames1, train_frames2,train_frames3,train_frames4,train_frames5, train_frames6))
我得到这个错误:
return _nx.concatenate(arrs, 1)
ValueError: all the input array dimensions except for the concatenation axis must match exactly
答案 0 :(得分:1)
解决如下:
train=np.concatenate([train_frames1, train_frames2,train_frames3,train_frames4,train_frames5, train_frames6],axis=0)
答案 1 :(得分:0)
试试这个: -
import numpy as np
train_frames1 = (2000, 1, 224, 224)
train_frames2 = (1000, 1, 224, 224)
train_frames3 = (2000, 1, 224, 224)
train_frames4 = (2000, 1, 224, 224)
train_frames5 = (2000, 1, 224, 224)
train_frames6 = (586, 1, 224, 224)
train=np.hstack((train_frames1, train_frames2,train_frames3,train_frames4,train_frames5, train_frames6))
print (train) #your output