我尝试使用已有的配置文件重新训练TF对象检测API模型的检查点,使用tf.estimator.train_and_evaluate()方法,就像models/research/object_detection/model_main.py中那样。它每N步或每N秒保存一次检查点。
但我想像Keras那样只保存一个最佳模型。使用TF对象检测API模型有办法做到吗?也许tf.Estimator.train有一些选项/回调,或者有什么方法可以将检测API与Keras一起使用?
回答:
你可以尝试使用BestExporter
。据我所知,这是你想要做的事情的唯一选择。
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