tensorflow.GraphDef was modified concurrently during serialization

tensorflow.GraphDef was modified concurrently during serialization_第1张图片

在超级参数不变的情况下,训练到390次再保存时,出现如下错误:

CHECK failed: (byte_size_before_serialization) == (byte_size_after_serialization): tensorflow.GraphDef was modified concurrently during serialization

网上搜索:原因是变量大多了,即saver存储的东西太大,超过了限制;

一路摸索,一路前进,几乎放弃的时候,通过对比前一版本的代码,主体思路多了个mask_noise时,就想到了,这个在每次迭代的时候都会新建个节点,如图所示:

tensorflow.GraphDef was modified concurrently during serialization_第2张图片

所以在这个地方每次迭代就会新建节点;所以saver存储的东西就越来越大;因为这个函数里面涉及到了tf张量和节点;即全局变量;

把这个往外移,然后再运行就完全没问题;容量也没有那么 大;原来训练390次就10个G,现在只有5个G;

结论:在训练迭代时就不能再新建任何变量和节点;tf的语句,每次执行都会新生成变量和节点;就会非常占据空间和容量;随着训练次数的增加,训练速度就会越来越慢;

你可能感兴趣的:(deep,learning,python)