[英]Your input ran out of data; interrupting training. Make sure that your dataset or generator can generate at least `steps_per_epoch * epochs` batches
I am trying to train a Neural Network model using Keras and need help with this error, which occurs when I try to run my train model:我正在尝试使用 Keras 训练神经网络 model 并且需要帮助解决此错误,当我尝试运行我的火车 model 时会发生此错误:
WARNING:tensorflow:Your input ran out of data; interrupting training. Make sure that your dataset or generator can generate at least `steps_per_epoch * epochs` batches (in this case, 19990 batches). You may need to use the repeat() function when building your dataset.
The code can be found here:代码可以在这里找到:
https://colab.research.google.com/drive/1hgQoo7Oz6UPIzQQ4ELwRUuPPNxaOAqeh?usp=sharing https://colab.research.google.com/drive/1hgQoo7Oz6UPIzQQ4ELwRUuPPNxaOAqeh?usp=sharing
I would suggest you use the fit()
instead of fit_generator()
method as TensorFlow already suggesting you.我建议您使用
fit()
而不是fit_generator()
方法,因为 TensorFlow 已经建议您了。
However, coming back to your issue, what's causing the problem actually is, when using generators you should let the model figure out how many steps are needed for an epoch to complete.但是,回到您的问题,实际上导致问题的原因是,使用生成器时,您应该让 model 计算出完成一个时期需要多少步骤。 If you manually set
steps_per_epoch
then you need to compute it correctly by yourself ( steps_per_epoch=(data_samples/batch_size)
), and with wrong calculation, this error occurs (that's what happened in your case).如果您手动设置
steps_per_epoch
那么您需要自己正确计算它( steps_per_epoch=(data_samples/batch_size)
),如果计算错误,就会发生此错误(这就是您的情况)。 So to prevent this issue you should simply remove the step_per_epoch
parameter when calling the fit_generator()
method and let the model handle step_per_epoch
value by itself, the code should work fine then.因此,为防止出现此问题,您
step_per_epoch
在调用fit_generator()
方法时删除 step_per_epoch 参数,并让 model 自行处理step_per_epoch
值,代码应该可以正常工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.