- Python Reinforcement Learning
- Sudharsan Ravichandiran Sean Saito Rajalingappaa Shanmugamani Yang Wenzhuo
- 178字
- 2021-06-24 15:17:29
Sessions
Computation graphs will only be defined; in order to execute the computation graph, we use TensorFlow sessions:
sess = tf.Session()
We can create the session for our computation graph using the tf.Session() method, which will allocate the memory for storing the current value of the variable. After creating the session, we can execute our graph with the sess.run() method.
In order to run anything in TensorFlow, we need to start the TensorFlow session for an instance; please refer to the code:
import tensorflow as tf
a = tf.multiply(2,3)
print(a)
It will print a TensorFlow object instead of 6. As already said, whenever we import TensorFlow a default computation graph will automatically be created and all nodes a that we created will get attached to the graph. In order to execute the graph, we need to initialize a TensorFlow session as follows:
#Import tensorflow
import tensorflow as tf
#Initialize variables
a = tf.multiply(2,3)
#create tensorflow session for executing the session
with tf.Session() as sess:
#run the session
print(sess.run(a))
The preceding code will print 6.
- 數(shù)據(jù)庫(kù)應(yīng)用實(shí)戰(zhàn)
- Word 2010中文版完全自學(xué)手冊(cè)
- Python數(shù)據(jù)分析入門(mén):從數(shù)據(jù)獲取到可視化
- 工業(yè)大數(shù)據(jù)分析算法實(shí)戰(zhàn)
- SQL查詢(xún):從入門(mén)到實(shí)踐(第4版)
- 算法與數(shù)據(jù)中臺(tái):基于Google、Facebook與微博實(shí)踐
- Mastering Machine Learning with R(Second Edition)
- 跟老男孩學(xué)Linux運(yùn)維:MySQL入門(mén)與提高實(shí)踐
- 數(shù)據(jù)庫(kù)設(shè)計(jì)與應(yīng)用(SQL Server 2014)(第二版)
- SQL Server深入詳解
- 數(shù)據(jù)庫(kù)技術(shù)及應(yīng)用
- Visual FoxPro數(shù)據(jù)庫(kù)技術(shù)基礎(chǔ)
- 從Lucene到Elasticsearch:全文檢索實(shí)戰(zhàn)
- Rust High Performance
- 數(shù)據(jù)會(huì)說(shuō)話(huà):活用數(shù)據(jù)表達(dá)、說(shuō)服與決策