我真的很困惑 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_epochs
是 None
,您的代码将无限迭代数据集。它将永远运行,允许您随时手动停止训练。例如,您可以手动监控您的训练和测试损失(和/或任何其他指标),以在模型收敛或开始过度拟合时停止训练。
关于tensorflow - 在 tensorflow estimator 中,num_epochs 为 None 意味着什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49761611/