我有一个已保存的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 ...
任何想法?
也许您可以如下尝试predictor。
from tensorflow.contrib import predictor
my_predict = predictor.from_saved_model(model_path)
prediction = my_predict({"x": [your_testing_data]})
希望这会有所帮助!