经常会遇见在训练过程中,运行越来越慢直至系统卡死,强制重启后重新训练又恢复。
知乎讨论:https://www.zhihu.com/question/58577743
Stackoverflow讨论:https://stackoverflow.com/questions/39070708/why-sometimes-tensorflow-runs-slower-and-slower-with-the-process-of-training
具体操作步骤:
tf.reset_default_graph() # 重置默认图 graph = tf.Graph() # 新建空白图 with graph.as_default() as g: # 将新建的图作为默认图 with tf.Session(graph=g): # Session 在新建的图中运行 # 需要运行的代码放这里,每次运行都会使用新的图