当将输入数据作为数组传递时,请勿指定`steps_per_epoch`/`steps`参数.请改用`batch_size` [英] When passing input data as arrays, do not specify `steps_per_epoch`/`steps` argument. Please use `batch_size` instead

查看:652
本文介绍了当将输入数据作为数组传递时,请勿指定`steps_per_epoch`/`steps`参数.请改用`batch_size`的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的代码如下:

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:生成器或Sequence的实例 (keras.utils.Sequence)对象,以避免在出现以下情况时出现重复数据 使用多重处理. 生成器的输出必须为 元组(输入,目标)...

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)...

您要传递数组,而不是 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`的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆