Predictions on a saved TensorFlow model from the Experiment framework -
i've trained , validated tensorflow model via experiment framework. i'm little lost on how can make predictions on new samples saved model. experiment code looks feature columns defined in previous cell:
def experiment_fn(output_dir): return tflearn.experiment( tflearn.dnnclassifier(feature_columns=feature_cols, hidden_units=[30, 2], n_classes=2, model_dir=output_dir), train_input_fn=get_train(), eval_input_fn=get_valid(), eval_metrics = { "accuracy": tf.contrib.learn.metricspec( metric_fn=tf.contrib.metrics.streaming_accuracy, prediction_key=tf.contrib.learn.predictionkey.classes), "precision": tf.contrib.learn.metricspec( metric_fn=tf.contrib.metrics.streaming_precision, prediction_key=tf.contrib.learn.predictionkey.classes), "recall": tf.contrib.learn.metricspec( metric_fn=tf.contrib.metrics.streaming_recall, prediction_key=tf.contrib.learn.predictionkey.classes) } ) learn_runner.run(experiment_fn, 'model_trained')
looking @ this post on saving , restoring model, thought may able retrieve predict method on dnnclassifier this:
op_to_restore = graph.get_tensor_by_name("predict:0")
and build feed_dict new samples , run:
print sess.run(op_to_restore,feed_dict)
however, after restoring model, tensorflow complains cannot find 'predict' operation.
any here appreciated. thanks!
Comments
Post a Comment