问题描述
我的代码如下:
model.fit_generator(generator=(train_image_list, train_mask_list),epochs=1000,shuffle=True)
train_image_list和train_mask_list都包含图像列表.当尝试在Google Colab中运行上述代码时,出现以下错误:
Both the train_image_list and train_mask_list contains image lists.When trying to run the above code in Google Colab I get the following error:
When passing input data as arrays, do not specify `steps_per_epoch`/`steps` argument. Please use `batch_size` instead.
在Keras文档中,fit_generator()未指定名为"batch_size"的参数.如何解决这个问题?
In the Keras documentation, fit_generator() do not specify a parameter called 'batch_size'. How to solve this issue?
推荐答案
这意味着您应该使用常规的fit()
方法,并指定batch_size
参数,而不是将数组作为生成器传递.
It means that you should use the normal fit()
method, and specify the batch_size
argument rather than passing arrays as generators.
model.fit(train_image_list, train_mask_list, epochs=1000, batch_size=32)
摘自 fit_generator()
的文档:
From the documentation of fit_generator()
:
您要传递数组,而不是 generator 对象.因此Keras告诉您,您不能以这种方式使用fit_generator
.
You're passing arrays, not a generator object. So Keras is telling you that you can't use fit_generator
this way.
这篇关于当将输入数据作为数组传递时,请勿指定`steps_per_epoch`/`steps`参数.请改用`batch_size`的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!