有什么方法只能使用tensorflow.estimator.train_and_evaluate()保存最佳模型吗? [英] Is there some way to save best model only with tensorflow.estimator.train_and_evaluate()?

查看:474
本文介绍了有什么方法只能使用tensorflow.estimator.train_and_evaluate()保存最佳模型吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用tf.estimator.train_and_evaluate()方法(已经在model / research / object_detection / model_main.py中)用已经的.config文件从检查点重新训练TF对象检测API模型,以训练管道。并且每N步或每N秒保存检查点。

I try retrain TF Object Detection API model from checkpoint with already .config file for training pipeline with tf.estimator.train_and_evaluate() method like in models/research/object_detection/model_main.py. And it saves checkpoints every N steps or every N seconds.

但是我只想保存一种最好的模型,例如Keras。
是否可以使用TF对象检测API模型来实现?也许是tf.Estimator.train的某些选项/回调,还是将检测API与Keras结合使用的某种方式?

But I want to save only one best model like in Keras. Is there some way to do it with TF Object Detection API model? Maybe some options/callbacks for tf.Estimator.train or some way to use Detection API with Keras?

推荐答案

您可以尝试使用 BestExporter 。据我所知,这是您要执行的操作的唯一选择。

You can try using BestExporter. As far as I know, it's the only option for what you're trying to do.

exporter = tf.estimator.BestExporter(
      compare_fn=_loss_smaller,
      exports_to_keep=5)

eval_spec = tf.estimator.EvalSpec(
    input_fn,
    steps,
    exporters)

https://www.tensorflow.org/api_docs/python/tf/estimator/BestExporter

这篇关于有什么方法只能使用tensorflow.estimator.train_and_evaluate()保存最佳模型吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆