tensorflow hook 与 early-stopping

有了hook可以更灵活的控制ckpt的存储时机与训练停止时机.

Estimator#fit(self,...,monitors=None)
训练时指定monitors参数, 接受的就是 BaseMonitor 对象.

early stopping

tensorflow.contrib.learn.python.learn.monitors.ValidationMonitor(..., every_n_steps,early_stopping_rounds, early_stopping_metric,early_stopping_metric_minimize)
ValidationMonitor类的构造. 可以看到early_stopping相关设置.

  • every_n_steps
    Check for new checkpoints to evaluate every N steps. If a new checkpoint is found, it is evaluated. See EveryN.

  • early_stopping_rounds:
    int. If the metric indicated by early_stopping_metric does not change according to early_stopping_metric_minimize for this many steps, then training will be stopped

参考

  1. tf-1.4 版本的文档见 SessionRunHook
  2. s.o.f 问答

你可能感兴趣的:(tensorflow hook 与 early-stopping)