[英]Is there any way to use tf.train.Checkpoint with MonitoredTrainingSession?
Now I am trying to use tf.train.Checkpoint instead of tf.train.Saver in various situations. 现在,我尝试在各种情况下使用tf.train.Checkpoint而不是tf.train.Saver。
When I tried to use Checkpoint with MonitoredTrainingSession, I noticed that Checkpoint.save changes tf.Graph. 当我尝试将Checkpoint与MonitoredTrainingSession一起使用时,我注意到Checkpoint.save更改了tf.Graph。 Therefore, I cannot use Checkpoint as follows.
因此,我不能如下使用Checkpoint。
a = tf.Variable([3], name="a")
checkpoint = tf.train.Checkpoint(model=a)
with tf.train.MonitoredTrainingSession() as sess:
checkpoint.save(file_prefix="parameter/ckpt", session=sess)
I got an error "RuntimeError: Graph is finalized and cannot be modified". 我收到一个错误“ RuntimeError:图形已完成,无法修改”。
Can I use Checkpoint with MonitoredTrainingSession? 我可以将Checkpoint与MonitoredTrainingSession一起使用吗?
I found a weird technique, which call checkpoint.write with a temporary session to construct a graph preliminarily. 我发现了一种怪异的技术,该技术使用一个临时会话调用checkpoint.write来初步构建图形。
with tf.Session() as sess:
sess.run(tf.global_variables_initializer())
checkpoint.save("./parameter/sample")
with tf.train.MonitoredTrainingSession() as sess:
checkpoint.save(file_prefix="parameter/ckpt", session=sess)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.