运行 在同一台机器上训练和评估的最佳做法是什么?

What is the best practice for running training and evaluation on the same machine?

我想做什么?

  1. 我只有一台机器。

  2. 我想定期评估模式。

我现在有什么?

  1. 使用占位符。假设我 运行 通过输入训练数据进行 1000 步训练。然后我输入验证数据集进行评估。把它放在一个循环中。

    但是正如 google 所建议的,占位符不是长时间 运行 训练的好方法。

  2. 因此,我使用 slim 数据集来输入数据。现在,该模型与训练数据集绑定如下:

     net = slim.conv2d(inputs, 64, [11, 11], 4, padding='VALID',
                                scope='conv1')
    

    我必须构建另一个与验证数据集绑定的模型(在另一个图中)。

有更好的方法吗?

tf.estimator.train_and_evaluate() API is designed to simplify training and evaluation on the same machine (and also includes support for scaling to multiple machines, either locally, or using Cloud ML Engine). Internally, it builds different graphs for training and evaluation, and connects different input pipelines (defined as "input functions") from a tf.estimator.TrainSpec and a tf.estimator.EvalSpec to those graphs. You can use the Slim API to build these input functions, but we now recommend that you use the tf.data API,更加灵活高效。