tensorflow - 在 tensorflow estimator 中,num_epochs 为 None 意味着什么?

标签 tensorflow tensorflow-estimator

我真的很困惑 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_epochsNone ,培训将永远运行?
它永远运行甚至意味着什么?

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

有人能解释一下吗?

回答我自己的问题:
我想我在这里找到了答案: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 ,您的代码将无限迭代数据集。它将永远运行,允许您随时手动停止训练。例如,您可以手动监控您的训练和测试损失(和/或任何其他指标),以在模型收敛或开始过度拟合时停止训练。

关于tensorflow - 在 tensorflow estimator 中,num_epochs 为 None 意味着什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49761611/

相关文章:

TensorFlow:如何使用 TensorHub 模块导出估算器?

tensorflow - ValueError : Shapes (None, 1) 和 (None, 2) 不兼容

java - 在Java中使用TensorFlow的Python Tensor

python - 在Tensorflow中,LSTMCell中状态元组(c,h)返回的 'output'和 'h'有什么区别?

python - 谁使用 tf.estimator.train_and_evaluate 提前停止评估损失?

tensorflow : Predict in Recurrent Neural Networks for Drawing Classification tutorial

Tensorflow:当我加载一个保存的模型并使用预测时,它给出了非常糟糕的结果。为什么? (我正在使用估算器 API)

python - 在AWS Sagemaker中使用Tensorflow Estimator时,训练作业是否会自动将模型工件保存到/opt/ml/model?

tensorflow - 相同的神经网络权重不应该产生相同的结果吗?

python - 为什么使用Anaconda环境在Windows上安装tensorflow?