在 tensorflow estimator 中,num_epochs 为 None 是什么意思?

In tensorflow estimator, what does it mean for num_epochs to be None?

我对 tensorflow 估计器 tf.estimator.inputs.numpy_input_fn here 的文档感到非常困惑,特别是 num_epochs:

上的那一行

num_epochs: Integer, number of epochs to iterate over data. If None will run forever.

如果我将 num_epochs 设置为 None,训练将永远 运行??
它永远 运行 甚至意味着什么?

这对我来说没有意义,因为我无法想象人们会以这样的方式设计程序,它可能 运行 永远。

谁能解释一下?


回答我自己的问题: 我想我已经在这里找到了答案:https://www.tensorflow.org/versions/r1.3/get_started/input_fn#evaluating_the_model

具体来说,在 Building the input_fn 部分:

Two additional arguments are provided: num_epochs: controls the number of epochs to iterate over data. For training, set this to None, so the input_fn keeps returning data until the required number of train steps is reached. For evaluate and predict, set this to 1, so the input_fn will iterate over the data once and then raise OutOfRangeError. That error will signal the Estimator to stop evaluate or predict.

如果 num_epochsNone,您的代码将无限遍历数据集。它将永远运行,允许您随时手动停止训练。例如,您可以手动监控训练和测试损失(and/or 任何其他指标),以便在模型收敛或开始过度拟合时停止训练。