- 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.
- 同步:秩序如何從混沌中涌現(xiàn)
- 程序員修煉之道:從小工到專家
- 分布式數(shù)據(jù)庫系統(tǒng):大數(shù)據(jù)時代新型數(shù)據(jù)庫技術(shù)(第3版)
- 文本數(shù)據(jù)挖掘:基于R語言
- 數(shù)據(jù)驅(qū)動設(shè)計:A/B測試提升用戶體驗
- 智能數(shù)據(jù)時代:企業(yè)大數(shù)據(jù)戰(zhàn)略與實戰(zhàn)
- 淘寶、天貓電商數(shù)據(jù)分析與挖掘?qū)崙?zhàn)(第2版)
- 區(qū)塊鏈技術(shù)應(yīng)用與實踐案例
- Visual Studio 2013 and .NET 4.5 Expert Cookbook
- 數(shù)據(jù)挖掘競賽實戰(zhàn):方法與案例
- 數(shù)據(jù)應(yīng)用工程:方法論與實踐
- 成功之路:ORACLE 11g學(xué)習(xí)筆記
- 數(shù)據(jù)挖掘與數(shù)據(jù)化運營實戰(zhàn):思路、方法、技巧與應(yīng)用
- 深入理解Flink:實時大數(shù)據(jù)處理實踐
- ORACLE 11g權(quán)威指南