python - 如何加载保存的 DNN 估计器模型进行预测?
问题描述
我有一个保存的 DNN 估计器模型。如何恢复模型进行预测?我使用以下方法保存了我的模型:
#Create the input function
input_func = tf.estimator.inputs.pandas_input_fn(x=X_train, y=y_train, batch_size=100, num_epochs=None, shuffle=True)
#Create the model
model = tf.estimator.DNNClassifier(feature_columns=feat_cols, hidden_units=[10, 10], n_classes=2, model_dir=model_path)
所以,在 model_path 目录中,我有:
- 检查点
- 事件.out.tf...
- 图.pbtxt
- 模型.ckpt-1...
- 模型.ckpt-1...
- 模型.ckpt-1...
- 型号.ckpt-5000...
- 型号.ckpt-5000...
- 型号.ckpt-5000...
任何想法?
解决方案
也许您可以尝试如下预测器。
from tensorflow.contrib import predictor
my_predict = predictor.from_saved_model(model_path)
prediction = my_predict({"x": [your_testing_data]})
希望这可以帮助!
推荐阅读
- tensorflow - 如何在 Keras 中定义 ConvLSTM 编码器解码器?
- r - purrr:加入嵌套在不同列表列中的小标题
- django - 用于前端的 Django Rest 框架视图和常规 django 视图
- .htaccess - 当名称包含问号 (?) 时重写
- c# - Int64 % Int32 给出 Int64 结果
- c# - 从 ASP.NET 菜单中删除菜单
- c# - 此文件转换代码中的性能问题是什么?
- joi - 使用 joi 验证库删除未知对象属性
- ios - 申请 HomePod
- powerbi - 嗨,我正在使用一些 DAX、度量值和表格来处理 Power BI,以获取最后一条记录,其中包含到期日期范围内的累积日期这里是表格