我有以下代码:
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 谁能告诉我这是什么问题?
答案 0 :(得分:1)
你能试试吗?
tf.get_collection(tf.GraphKeys.VARIABLES)
这应该为你提供所有可训练和无法控制的变量......