【发布时间】:2021-04-26 21:08:17
【问题描述】:
new_img = []
images = list(df['pixels'])
for image in images:
image = image.split()
new_img.append(image)
new_img = np.array(new_img)
new_img = new_img.astype('float32')/255
new_img = new_img.reshape(df.shape[0], 48, 48, 1)
new_img = tf.image.resize(new_img(297,297))
在上面的代码(最后一行)中,我试图调整整个数据集(35000 个元素)的大小。 但是 Google Colab 会耗尽所有 RAM。 请问有没有其他方法可以解决这个问题?
提前谢谢你。
【问题讨论】:
-
最后一行应该做什么?你为什么打电话给
new_img? -
@NicolasGervais 我已经编辑了代码。数据集包括图像。我已经对它们进行了处理,以便将它们包含在模型中进行训练。在最后一步中,我想将所有图像的大小从 48,48 调整为 297,297。但是它用完了内存,因为有很多图像(大约 35000 个)当我调整 1 个图像的大小时,代码是正确的。但是对于整个数据集,计算能力不够,ram用完了
标签: python numpy tensorflow google-colaboratory