我正在尝试将数组复制到矩阵(以填充行),如下所示:
image = cv2.imread(file)
feature = image.reshape((IMAGE_LEN, -1))
features_matrix[0] = np.copy(feature[0:])
但出现以下错误:
ValueError: could not broadcast input array from shape (150528,1) into shape (150528)
features_matrix的大小正确(
np.zeros((NUM_OF_FILES_PER_LABEL,IMAGE_LEN))
和
feature[0:]
(或feature[0::]
)适合此大小。print (feature.shape) gives (150528,1)
那么什么地方出了问题,我该如何解决?
(我正在使用python 3.7)
最佳答案
试试image.reshape((IMAGE_LEN))
关于python - ValueError:无法将输入数组从形状(150528,1)广播到形状(150528),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56803293/