[英]How to load a saved DNN estimator model for predicting?
我有一个保存的 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...
- 图.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]})
希望这可以帮助!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.