2015-11-13 199 views
7

我得到TF正常工作为CIFAR Tutorial。 我已经更改了代码以将train_dir(带检查点和模型的目录)保存到知道的位置。如何在Tensorflow中暂停/恢复训练

张量板似乎与特定的train_dir正常工作,它可以通过网络界面给我一个监督工具。

我设法运行cifar10_eval.py,与正确的目录路径,我收到了效果,一些警告一起..(看来我会更多的GPU资源,没有警告的情况下...)

2015年11月13日10:09:30.278728:精密@ 1 = 0.101

W¯¯tensorflow /型芯/ common_runtime/executor.cc:1027] 0x7fea7c0547c0计算状态:取消:排队操作被取消 [[ Node:input_producer/input_producer_EnqueueMany = QueueEnqueueMany [Tcomponents = [DT_STRING],timeout_ms = -1,_device =“/ j OB:本地主机/复制:0 /任务:0/CPU:0" ](input_producer,input_producer/RandomShuffle)]]

我tensorflow /型芯/核/ fifo_queue.cc:154]跳过取消排队尝试

W tensorflow/core/common_runtime/executor.cc:1027] 0x7fea2c0024e0计算状态:中止:RandomShuffleQueue'_2_shuffle_batch/random_shuffle_queue'已关闭。 [[node:shuffle_batch/random_shuffle_queue_enqueue = QueueEnqueue [Tcomponents = [DT_FLOAT,DT_INT32],timeout_ms = -1,_device =“/ job:localhost/replica:0/task:0/cpu:0”](shuffle_batch/random_shuffle_queue, Div/_23,Cast)]]

W tensorflow/core/common_runtime/executor.cc:1027] 0x7fea50003b80计算状态:中止:RandomShuffleQueue'_2_shuffle_batch/random_shuffle_queue'已关闭。 [[node:shuffle_batch/random_shuffle_queue_enqueue = QueueEnqueue [Tcomponents = [DT_FLOAT,DT_INT32],timeout_ms = -1,_device =“/ job:localhost/replica:0/task:0/cpu:0”](shuffle_batch/random_shuffle_queue, DIV/_23,CAST)]]

...

这让我想起我的问题:我怎样可以暂停和恢复一些培训TF

回答

12

TensorFlow使用图形计算,节点(Ops)和边缘(变量又名状态),它为它的Vars提供Saver

因此,由于它是分布式计算,您可以在一台机器/处理器中运行一部分图形,其余部分运行在另一台机器上,同时您可以保存状态(Vars)并在下一次进给时继续工作。

saver.save(sess, 'my-model', global_step=0) ==> filename: 'my-model-0' 
... 
saver.save(sess, 'my-model', global_step=1000) ==> filename: 'my-model-1000' 

后来你可以使用

tf.train.Saver.restore(sess, save_path) 

恢复已保存的瓦尔。

Saver Usage

+0

使用该命令tf.train.Saver.restore(SESS,的save_path)将导致错误,因为恢复方法需要保护程序实例。 – Kongsea