张量流中是否有内置的早期停止功能?我检查了由tf.Estimator提供的钩子,找不到任何东西。或者我需要自己实施?
答案 0 :(得分:0)
@Maxime, 实验有效!这是我的代码的一部分,以防您对答案感兴趣。在contrib中有特征,所以它可能不稳定。
config = tf.contrib.learn.RunConfig(model_dir=FLAGS.train_dir)
# config = config.replace(sess_config=sess_config)
tf.logging.set_verbosity(logging.INFO)
validation_monitor = monitors.ValidationMonitor(
input_fn=functools.partial(input_fn, subset="evaluation"),
eval_steps=128,
every_n_steps=101,
early_stopping_metric="accuracy",
early_stopping_rounds = 1000
)
run_monitors = [validation_monitor]
tf.contrib.learn.learn_runner.run(
get_experiment_fn(train_input_fn=functools.partial(input_fn,subset="training"),
eval_input_fn=functools.partial(input_fn,subset="evaluation"),
train_steps=FLAGS.train_steps,
eval_steps=100,
train_hooks=run_monitors,
model_fn=model_fn_cnn
),
run_config = config
)