2

在 Keras 中,您可以使用以下方法加载您之前训练过的模型:

训练好的_keras_model = tf.keras.models.load_model(model_name)

有没有使用 TensorFlow estimator API 的等效方法?根据文档,我必须使用:

trained_estimator = tf.estimator.Estimator (model_fn,model_dir) 我想只使用模型目录中的文件来获得训练有素的估计器。更清楚地说,我的想法是在没有 model_fn 源代码的情况下从磁盘加载“任何”模型。有可能这样做吗?

这个功能是在 Keras 中实现的,所以我不明白为什么 Estimator API 不能做到这一点。

4

1 回答 1

2

我会用Estimator.export_savedmodel(). 这将以适合服务的格式保存权重 + 图表。您还可以查看https://github.com/ajbouh/tfiSavedModel ,了解从 Python中使用 s 的超级简单方法(但使用TensorFlow 服务于生产用例)。

于 2018-02-15T20:22:23.030 回答