python - 将输入数据作为数组传递时,请勿指定 `steps_per_epoch`/`steps` 参数。请使用 `batch_size` 代替

标签 python tensorflow machine-learning keras deep-learning

我的代码如下:

model.fit_generator(generator=(train_image_list, train_mask_list),epochs=1000,shuffle=True)

train_image_list 和 train_mask_list 都包含图像列表。当尝试在 Google Colab 中运行上述代码时,出现以下错误:

When passing input data as arrays, do not specify `steps_per_epoch`/`steps` argument. Please use `batch_size` instead.

在 Keras 文档中,fit_generator() 没有指定名为“batch_size”的参数。如何解决这个问题?

最佳答案

这意味着您应该使用普通的 fit() 方法,并指定 batch_size 参数,而不是将数组作为生成器传递。

model.fit(train_image_list, train_mask_list, epochs=1000, batch_size=32)

来自 fit_generator() 的文档:

generator: A generator or an instance of Sequence (keras.utils.Sequence) object in order to avoid duplicate data when using multiprocessing. The output of the generator must be either a tuple (inputs, targets)...

您正在传递数组,而不是生成器对象。因此 Keras 告诉您不能以这种方式使用 fit_generator

关于python - 将输入数据作为数组传递时,请勿指定 `steps_per_epoch`/`steps` 参数。请使用 `batch_size` 代替,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59218782/

相关文章:

python - 当试图模糊图像时,图像向左转

python - 从表格中提取 <b> 文本

c++ - 嵌入python报错Import by filename is not supported

python - 如何使用 Chalice 处理 DynamoDB 流事件

python - 如何从特定类别中抽样批处理?

python - Tensorflow - 显示和手动修改学习模型的权重并导出以供进一步重新学习

.jpeg 文件的 Python 导入文件夹

tensorflow - 在 Tensorflow 的 DNNClassifier 估计器中记录设备信息

python - 无法理解 pandas 中的预测算法

machine-learning - 如何使用给出图像数据集的数据集训练模型,并在单独的 csv 文件中给出该图像的标签?