I'm trying to load a saved model by saver and evaluate the output of the network over the test data, restoring a saved model and using the network as a function:
def model(x, x_size):
with tf.variable_scope("my_net", reuse=tf.AUTO_REUSE):
W1 = tf.get_variable('w1', [x_size, x_size],
initializer=tf.random_normal_initializer())
b1 = tf.get_variable('b1', [x_size],
initializer=tf.random_normal_initializer())
y1 = tf.nn.relu(tf.matmul(x, W1) + b1,'y1')
return y1
eval_x = tf.placeholder(tf.float32, name='eval_x', shape=[None, x_size])
eval_probs = model(eval_x, x_size)
with tf.Session() as sess:
new_saver = tf.train.import_meta_graph('save_model/model.ckpt.meta')
new_saver.restore(sess, "save_model/model.ckpt")
probs = sess.run(eval_probs, feed_dict={eval_x: test_x})
The error I get is:
FailedPreconditionError (see above for traceback): Attempting to use uninitialized value my_net/w1 [[Node: my_net/w1/read = IdentityT=DT_FLOAT, _class=["loc:@my_net/w1"], _device="/job:localhost/replica:0/task:0/device:CPU:0"]]
Can anybody help?