In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly introduces the TensorFlow visualization tool TensorBoard default diagram and custom diagram example analysis, has a certain reference value, interested friends can refer to, I hope you read this article after a lot of gains, the following let Xiaobian take you to understand.
I. Figure
Figure: Data (Tensor)+ Operation (Node Operation)(Static)
Figure can be used: 1, default map;2, custom map.
1. Default graph
How to view default graphs:
1. Call method: tf.get_default_graph()
2. View attributes: .graph
1. Call method View default graph attributes #Method 1: Call method default = tf.get_default_graph() print('default:', default)
2.graph View graph attributes #Method 2: View attributes #View node properties print ('a's attributes:', a.graph) print ('c's attributes:', c.graph) #View session properties print ('session sess graph properties', sess.graph)
It can be seen that the addresses of these graphs are all the same, because they all use the default graph by default.
Code #View Default Graph def View_Graph(): #Method 1: Call Method default = tf.get_default_graph() print('default:', default) #Method 2: View Properties #View node properties print ('a's attributes:', a.graph) print ('c's attributes:', c.graph) #View session properties print ('session sess graph properties', sess.graph)2. Custom graph (Create graph) 1. Create custom graph # 1 Create custom graph new_graph = tf.Graph() print(new_graph)
2. Create Static Graph # 2 Create Static Graph (Tensors and Nodes) with new_graph.as_default(): a = tf.constant(10) b = tf.constant(20) c = a + b print(c)3. Open Session (Run)# 3 Open Session (Run) with tf.Session(graph=new_graph) as sess: print('c=', sess.run(c))
4. View custom diagrams #4 View custom diagrams View_Graph(a, b, c, sess)#def View_Graph(a, b, c, sess): #Method 1: Call Method default = tf.get_default_graph() print('default:', default) #Method 2: View Properties #View node properties print ('a's attributes:', a.graph) print ('c's attributes:', c.graph) #View session properties print ('session sess graph properties', sess.graph)
Code #Custom Graph def Create_myGraph(): # 1 Create a custom diagram new_graph = tf.Graph() print(new_graph) # 2 Create Static Graphs (Tensors and Nodes) with new_graph.as_default(): a = tf.constant(10) b = tf.constant(20) c = a + b print(c) #3 Start Conversation (Run) with tf.Session(graph=new_graph) as sess: print('c=', sess.run(c)) #4 View custom diagrams View_Graph(a, b, c, sess) II. TensorBoard visualization 1. Visualization tf.summary.FileWriter(path, graph=)#Visualization tf.summary.FileWriter("C:\\Users\\Administrator\\Desktop\\summary", graph=sess.graph) #path Figure 2: Open TensorBoard
In cmd:
1. Move to the front of the folder cd C://Users//Administrator//Desktop2. Open TensorBoard (get data from files) tensorboard --logdir=summary
3. Open a given URL
http://localhost:6006/(URL given in cmd)
Get visual results:
Total code import tensorflow as tf#Create TensorFlow framework def Create_Tensorflow(): #Graph (static) a = tf.constant(2) #data 1 (tensor) b = tf.constant(6) #data 2 (tensor) c = a + b #operation (node) #Session (Execution) with tf.Session() as sess: print('c=', sess.run(c)) #Visualize tf.summary.FileWriter("C:\\Users\\Administrator\\Desktop\\summary", graph=sess.graph) #View default graph View_Graph(a, b, c, sess) #def View_Graph(a, b, c, sess): #Method 1: Call Method default = tf.get_default_graph() print('default:', default) #Method 2: View Properties #View node properties print ('a's attributes:', a.graph) print ('c's attributes:', c.graph) #View session properties print ('session sess graph properties', sess.graph) #custom graph def Create_myGraph(): # 1 Create a custom diagram new_graph = tf.Graph() print(new_graph) # 2 Create Static Graphs (Tensors and Nodes) with new_graph.as_default(): a = tf.constant(10) b = tf.constant(20) c = a + b print(c) #3 Start Conversation (Run) with tf.Session(graph=new_graph) as sess: print('c=', sess.run(c)) #4 View custom diagrams View_Graph(a, b, c, sess) if __name__ == '__main__': #Create TensorFlow Framework Create_Tensorflow() #Create custom diagrams Create_myGraph() Thank you for reading this article carefully. I hope that the article "Example analysis of TensorBoard default graph and custom graph in TensorFlow visualization tool" shared by Xiaobian will be helpful to everyone. At the same time, I hope that everyone will support it a lot. Pay attention to the industry information channel. More relevant knowledge is waiting for you to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.