Created
February 8, 2017 07:09
-
-
Save benwu232/6b90d6571cc19c5ebb5294919d9f677d to your computer and use it in GitHub Desktop.
Describe how to use tensorflow to save model, parameters, inputs and outputs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tensorflow as tf | |
tf.GraphKeys.USEFUL = 'useful' | |
v1 = tf.placeholder(tf.float32, name="v1") | |
v2 = tf.placeholder(tf.float32, name="v2") | |
v3 = tf.mul(v1, v2) | |
vx = tf.Variable(10.0, name="vx") | |
v4 = tf.add(v3, vx, name="v4") | |
tf.add_to_collection(tf.GraphKeys.USEFUL, v1) | |
tf.add_to_collection(tf.GraphKeys.USEFUL, v2) | |
tf.add_to_collection(tf.GraphKeys.USEFUL, v4) | |
saver = tf.train.Saver([vx]) | |
sess = tf.Session() | |
sess.run(tf.initialize_all_variables()) | |
sess.run(vx.assign(tf.add(vx, vx))) | |
result = sess.run(v4, feed_dict={v1:12.0, v2:3.3}) | |
print(result) | |
saver.save(sess, "./model_ex1") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment