The number of training iterations is a hyperparameter we can optimize automatically using a technique called early stopping (also "early termination").
SessionRunHook
More recent versions of TensorFlow deprecated monitors in favor ofSessionRunHooks. SessionRunHooks are an evolving part of tf.train, and going forward appear to be the proper place where you'd implement early stopping.
At the time of writing, two pre-defined stopping monitors exist as a part of tf.train'straining hooks:
- StopAtStepHook: A monitor to request the training stop after a certain number of steps
- NanTensorHook: a monitor that monitor's loss and stops training if it encounters a NaN loss