【tensorflow】重置/清除计算图
生活随笔
收集整理的這篇文章主要介紹了
【tensorflow】重置/清除计算图
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
轉自:https://blog.csdn.net/u014636245/article/details/84073239,侵刪
當在搭建網絡查看計算圖時,如果重復運行程序會導致重定義報錯。為了可以在同一個線程或者交互式環境中(ipython/jupyter)重復調試計算圖,就需要使用這個函數來重置計算圖,隨后修改計算圖再次運行。
#重置計算圖,清理當前定義節點 import tensorflow as tf tf.reset_default_graph()#Your model defined below #需要注意的是,下面三種情況使用這個函數會報錯:
#1 with graph.as_default():#不能用#2 with tf.Session(): block.#不能用 #3 tf.InteractiveSession() #Your regions #不能用 sess.close().也就是說這個函數需要在with tf.session()外部調用。
ref:
https://stackoverflow.com/questions/46893824/do-not-use-tf-reset-default-graph-to-clear-nested-graphs
https://www.w3cschool.cn/tensorflow_python/tensorflow_python-nmgf2idd.html
總結
以上是生活随笔為你收集整理的【tensorflow】重置/清除计算图的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Gumbel-Softmax Trick
- 下一篇: tensorflow 添加官方代码--以