Tensorflow中的Session() 與InteractiveSession()
阿新 • • 發佈:2019-01-24
今天學習tensorflow時發現除了Session()外,竟然還有個InteractiveSession()。這就讓我這個初學者又開始抓耳撓腮的想了,這兩者有什麼不同呢,還要設定兩個會話型別。現在將其兩者的差別簡單寫一下,後期根據自己的學習狀態及理解會不斷的更新。
在教學網站上看到一段對InteractiveSession()的描述語:
One major change is the use of an before you run it.
不同點1、
最為主要的一句話當屬第一句:使用
InteractiveSession
, which allows us to run variables without needing to
constantly refer to the session object (less typing!). Code blocks below are broken into different cells. If you see a break in the code, you will need to run the previous cell first. Also, if you aren’t otherwise confident,
ensure all of the code in a given block is type into a cell InteractiveSession
一個主要的變化是:執行在沒有指定會話物件的情況下執行變數。這是與Session()最大的不同。
不同點2、
Session()使用with..as..後可以不使用close關閉對話,而呼叫InteractiveSession需要在最後呼叫close