- 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.
- 計(jì)算機(jī)綜合設(shè)計(jì)實(shí)驗(yàn)指導(dǎo)
- 數(shù)據(jù)挖掘原理與實(shí)踐
- Word 2010中文版完全自學(xué)手冊(cè)
- Python廣告數(shù)據(jù)挖掘與分析實(shí)戰(zhàn)
- 企業(yè)大數(shù)據(jù)系統(tǒng)構(gòu)建實(shí)戰(zhàn):技術(shù)、架構(gòu)、實(shí)施與應(yīng)用
- 基于OPAC日志的高校圖書(shū)館用戶信息需求與檢索行為研究
- 數(shù)據(jù)庫(kù)設(shè)計(jì)與應(yīng)用(SQL Server 2014)(第二版)
- 商業(yè)智能工具應(yīng)用與數(shù)據(jù)可視化
- 大數(shù)據(jù)時(shí)代系列(套裝9冊(cè))
- Visual Studio 2012 and .NET 4.5 Expert Development Cookbook
- Learning Ansible
- AI Crash Course
- 數(shù)字化轉(zhuǎn)型方法論:落地路徑與數(shù)據(jù)中臺(tái)
- Practical Convolutional Neural Networks
- 精通Neo4j