I am utilising tensorflow v 1.12 to run some old machine learning code. I am trying to separate the training and the testing process into different files. After training the model for a certain number of iterations, i call the
train.py
restorer = tf.train.import_meta_graph(save_path + '.meta')
restorer.restore(sess, save_path)
In the test file I load the model as follows:
test.py
with tf.Session() as sess:
restorer = tf.train.import_meta_graph(save_path + '.meta')
restorer.restore(sess, save_path = save_path)
env_model = EnvModel() # create model used in do_eval function
est, actual, error = do_eval(test_df)
and in the do_eval function, there is a
est_next_state,loss = sess.run([env_model.est_next_state,env_model.loss],
feed_dict={env_model.cur_state:states,
env_model.next_state:next_states,
env_model.actions:actions,
env_model.done_flags:done_flags,
env_model.phase:False})
I get an error tensorflow.python.framework.errors_impl.FailedPreconditionError: Attempting to use uninitialized value BatchNorm_1/moving_mean_5
It seems that in tensorflow v1, I am only able to load the tensorflow model within the training script itself ?