2017-03-03 54 views
0

变量我有下面的代码:无法加载在Tensorflow

sess = tf.Session() 
model_file = './runs/1488368349/checkpoints/model-42200.meta' 
checkpoint_dir = './runs/1488368349/checkpoints/' 


new_saver = tf.train.import_meta_graph(model_file) 
#new_saver.restore(sess, MODEL_PATH) 
new_saver.restore(sess, tf.train.latest_checkpoint(checkpoint_dir)) 

all_vars = tf.get_collection('vars') 
print len(all_vars) 
for v in all_vars: 
     v_ = sess.run(v) 
     print(v_) 

但上面的代码是无法加载变量。我得到的all_vars的长度为0.
有人可以告诉我什么是问题?

回答

1

你可以试试吗?

tf.get_collection(tf.GraphKeys.VARIABLES) 

这应该给你的所有训练的和untrainable变量...