Ch 02: Concept 07

Loading variables

Concept 06 was about saving variables. This one's about loading what you saved. Start by creating an interactive session:


In [1]:
import tensorflow as tf
sess = tf.InteractiveSession()

Create a boolean vector called spikes of the same dimensions as before:


In [2]:
spikes = tf.Variable([False]*8, name='spikes')

Restored the variable data from disk, serve warm, and enjoy:


In [3]:
saver = tf.train.Saver()

try:
    saver.restore(sess, 'spikes.ckpt')
    print(spikes.eval())
except:
    print('file not found')


file not found

Show's over, goodnight:


In [4]:
sess.close()