我的代码如下:
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/