简体   繁体   English

您输入的数据用完了; 中断训练。 确保您的数据集或生成器至少可以生成 `steps_per_epoch * epochs` 批次

[英]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.

相关问题 您输入的数据不足; 中断训练。 确保您的数据集或生成器至少可以生成`steps_per_epoch - Your input ran out of data; interrupting training. Make sure that your dataset or generator can generate at least `steps_per_epoch 训练时出错:tensorflow:你的输入数据用完了; 中断训练 - Error while training: tensorflow:Your input ran out of data; interrupting training 'tf.data()' throwing 你的输入数据用完了; 中断训练 - 'tf.data()' throwing Your input ran out of data; interrupting training 即使指定了steps_per_epoch,自定义生成器也会耗尽数据 - Custom generator runs out of data even when steps_per_epoch specified 输入的数据用完了; 中断训练 - input ran out of data; interrupting training fit_generator中的Keras steps_per_epoch如何工作 - How the Keras steps_per_epoch in fit_generator works Keras Sequence,fit_generator和steps_per_epoch - Keras Sequence, fit_generator and steps_per_epoch TensorFlow keras 模型 fit() 参数 steps_per_epoch 和训练集上的 epochs 行为 - TensorFlow keras model fit() parameters steps_per_epoch and epochs behavior on train set tensorflow:您的输入数据用完 - tensorflow:Your input ran out of data Keras 2 fit_generator UserWarning:`steps_per_epoch`与Keras 1参数`samples_per_epoch`不同 - Keras 2 fit_generator UserWarning: `steps_per_epoch` is not the same as the Keras 1 argument `samples_per_epoch`
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM