1.首先要将训练好的模型保存下来,保存代码如下:
import tensorflow as tf
sess = tf.Session()
saver = tf.train.Saver()
model_path = '/home/../model.ckpt'
saver.save(sess,model_path)
2.对保存的模型进行调用,代码如下:
import tensorflow as tf
sess = tf.Session()
saver =tf.train.Saver()
saver.restore(sess,model_path)
y = sess.run(y,feed_dict={x:data})
这样就可以实现调用模型来通过输入数据data来预测y的值了。