【发布时间】:2021-07-18 13:21:55
【问题描述】:
根据我的代码,我想读取帧并将它们转换为数组。之后使用 np.array 如下:
img = Image.open(os.path.join(source_folder, item))
frames.append(item)
x.append(np.asarray(img))
w.append(np.array(x[i]))
当我运行波纹管时
w_train, w_test, y_train, y_test =train_test_split(w, y, test_size=0.2 ,shuffle=True, random_state=42)
w_train = w_train.reshape(2404,28,224,224,3)
w_test = w_test.reshape(601,28,224,224,3)
当我想使用 reshape 时,我面临 w_train 的这个错误:
AttributeError Traceback (most recent call last)
<ipython-input-6-809eb2542c50> in <module>
----> 9 w_train = w_train.reshape(2404,28,224,224,3)
10 w_test = w_test.reshape(601,28,224,224,3)
AttributeError: 'list' object has no attribute 'reshape'
【问题讨论】:
-
np.array(w_train).reshape(2404, 28, 224, 224, 3) ?
-
w_train 的形状是 (67312,224,224,2)。我想将其重塑为(2404,28,224,224,3)。我该怎么办?
标签: python-3.x machine-learning reshape