如何加载保存的DNN估计器模型进行预测?

问题描述 投票:0回答:1

我有一个已保存的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目录中,我有:

  • 检查点
  • event.out.tf ...
  • graph.pbtxt
  • model.ckpt-1 ...
  • model.ckpt-1 ...
  • model.ckpt-1 ...
  • model.ckpt-5000 ...
  • model.ckpt-5000 ...
  • model.ckpt-5000 ...

任何想法?

python tensorflow model restore tensorflow-estimator
1个回答
0
投票

也许您可以如下尝试predictor

from tensorflow.contrib import predictor

my_predict = predictor.from_saved_model(model_path)
prediction = my_predict({"x": [your_testing_data]})

希望这会有所帮助!

© www.soinside.com 2019 - 2024. All rights reserved.