- TensorFlow Machine Learning Projects
- Ankit Jain Armando Fandango Amita Kapoor
- 202字
- 2021-06-10 19:15:30
Multiple graphs
We can create our own graphs, which are separate from the default graph, and execute them in a session. However, creating and executing multiple graphs is not recommended, because of the following disadvantages:
- Creating and using multiple graphs in the same program would require multiple TensorFlow sessions, and each session would consume heavy resources
- Data cannot be directly passed in-between graphs
Hence, the recommended approach is to have multiple subgraphs in a single graph. In case we wish to use our own graph instead of the default graph, we can do so with the tf.graph() command. In the following example, we create our own graph, g, and execute it as the default graph:
g = tf.Graph()
output = 0
# Assume Linear Model y = w * x + b
with g.as_default():
# Define model parameters
w = tf.Variable([.3], tf.float32)
b = tf.Variable([-.3], tf.float32)
# Define model input and output
x = tf.placeholder(tf.float32)
y = w * x + b
with tf.Session(graph=g) as tfs:
# initialize and print the variable y
tf.global_variables_initializer().run()
output = tfs.run(y,{x:[1,2,3,4]})
print('output : ',output)
Now, let's put this learning into practice and implement the classification of handwritten digital images with TensorFlow.
推薦閱讀
- 大數(shù)據(jù)挑戰(zhàn)與NoSQL數(shù)據(jù)庫技術(shù)
- iClone 4.31 3D Animation Beginner's Guide
- 計算機(jī)網(wǎng)絡(luò)技術(shù)基礎(chǔ)
- 統(tǒng)計學(xué)習(xí)理論與方法:R語言版
- JavaScript典型應(yīng)用與最佳實(shí)踐
- Grome Terrain Modeling with Ogre3D,UDK,and Unity3D
- R Machine Learning Projects
- 電子設(shè)備及系統(tǒng)人機(jī)工程設(shè)計(第2版)
- Unity Multiplayer Games
- Linux系統(tǒng)下C程序開發(fā)詳解
- Unreal Development Kit Game Design Cookbook
- 基于Proteus的PIC單片機(jī)C語言程序設(shè)計與仿真
- 軟件測試管理
- Mastercam X5應(yīng)用技能基本功特訓(xùn)
- SQL語言與數(shù)據(jù)庫操作技術(shù)大全