Skip to content

Instantly share code, notes, and snippets.

@hadifar
Last active December 2, 2018 10:10
Show Gist options
  • Save hadifar/57bfcee17ed9630e2cda027f5f6a9820 to your computer and use it in GitHub Desktop.
Save hadifar/57bfcee17ed9630e2cda027f5f6a9820 to your computer and use it in GitHub Desktop.
import tensorflow as tf
v1 = tf.Variable(80., name="v1")
v2 = tf.Variable(10., name="v2")
a = tf.add(v1, v2)
saver0 = tf.train.Saver(var_list=[v1, v2])
saver1 = tf.train.Saver(var_list={'myVar1': v1, 'myVar2': v2})
saver2 = tf.train.Saver(var_list={'myVar1': v1})
saver3 = tf.train.Saver(var_list=tf.trainable_variables())
saver = tf.train.Saver()
with tf.Session() as sess:
sess.run(tf.global_variables_initializer())
saver.save(sess, './saver_test/myVar')
saver.restore(sess, './saver_test/myVar')
print(sess.run(v1))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment