tensorflow - 是否可以从保存的模型中恢复 tensorflow 估计器?

标签 tensorflow tensorflow-estimator

我用 tf.estimator.train_and_evaluate()训练我的自定义估算器。我的数据集按 8:1:1 进行分区,用于训练、评估和测试。在训练结束时,我想恢复最佳模型,并使用 tf.estimator.Estimator.evaluate() 评估模型。与测试数据。目前使用 tf.estimator.BestExporter 导出最佳模型.

虽然 tf.estimator.Estimator.evaluate()接受 checkpoint_path并恢复变量,我找不到任何简单的方法来使用 tf.estimator.BestExporter 生成的导出模型.我当然可以在训练期间保留所有检查点,并自己寻找最佳模型,但这似乎不太理想。

谁能告诉我一个简单的解决方法?也许可以将保存的模型转换为检查点?

最佳答案

也许你可以试试 tf.estimator.WarmStartSettings: https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/estimator/WarmStartSettings
它可以在 pb 文件中加载权重并继续训练,这对我的项目有效。
您可以按如下方式设置热启动:

ws = WarmStartSettings(ckpt_to_initialize_from="/[model_dir]/export/best-exporter/[timestamp]/variables/variables")
然后一切都会好起来的

关于tensorflow - 是否可以从保存的模型中恢复 tensorflow 估计器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53184109/

相关文章:

tensorflow - 在linux上构建tensorflow时出错

python - Tensorflow:如何在序列长度不同的 RNN 输出中添加偏差

tensorflow - tf.data.Dataset 是否支持生成字典结构?

python - 在 GPU 上执行外部优化器

python - 逻辑 'AND' 的 Tensorflow 自定义估计器

tensorflow - keras中的fit_generator : where is the batch_size specified?

tensorflow - 有谁知道我们如何更改 DNNClassifier tensorflow 预制估计器中的损失函数?

python - 为什么要在 tensorflow 中构建用于训练和验证的分离图?

python - 使用 AdamOptimizer 继续训练自定义 tf.Estimator

python - 将 Tensorflow 分析器与 tf.Estimator 结合使用