I. Chart
Graph: Data (Tensor Tenrsor) + Operation (Node Operation) (Static)
The diagram can be used: 1. default diagram; 2. customized diagram.
1. Default Chart
A way to view the default diagram:
- 1. Call method: tf.get_default_graph()
- 2. View properties: .graph
1, call the method to view the default map properties
# Method I: Invocation method default = tf.get_default_graph() print('default:', default)
2, .graph view graph properties
# Method 2: View Properties # View node properties print('Attributes of a:', ) print('Attributes of c:', ) # View session properties print('Graph properties for session sess:', )
The reason you can notice that these graphs all have the same address is because they all use the default graph by default.
coding
# View Default Chart def View_Graph(): # Method I: Invocation method default = tf.get_default_graph() print('default:', default) # Method 2: View Properties # View node properties print('Attributes of a:', ) print('Properties of c:', ) # View session properties print('Graph properties for session sess:', )
2. Customized diagrams (creation of diagrams)
1、Create customized diagram
# 1 Create a customized diagram new_graph = () print(new_graph)
2、Create static diagram
# 2 Create static graphs (tensor and nodes) with new_graph.as_default(): a = (10) b = (20) c = a + b print(c)
3. Open session (run)
# 3 Open dialog (running) with (graph=new_graph) as sess: print('c=', (c))
4、View customized diagram
# 4 Viewing Customized Diagrams View_Graph(a, b, c, sess)
# View Figure def View_Graph(a, b, c, sess): # Method 1: Invocation method default = tf.get_default_graph() print('default:', default) # Method 2: View Properties # View node properties print('Attributes of a:', ) print('Properties of c:', ) # View session properties print('Graph properties for session sess:', )
coding
# Customization charts def Create_myGraph(): # 1 Create a customized diagram new_graph = () print(new_graph) # 2 Create static graphs (tensor and nodes) with new_graph.as_default(): a = (10) b = (20) c = a + b print(c) # 3 Open dialog (running) with (graph=new_graph) as sess: print('c=', (c)) # 4 Viewing Customized Diagrams View_Graph(a, b, c, sess)
II. TensorBoard Visualization
1、Visualization processing
(path, graph=)
# Visualization ("C:\\Users\\Administrator\\Desktop\\summary", graph=) #path seek
2. Open TensorBoard
Operate in cmd:
1. Move to the front of the folder first
cd C://Users//Administrator//Desktop
2. Open TensorBoard (get data from file)
tensorboard --logdir=summary
3. Open the given URL
http://localhost:6006/ (URL given in cmd)
Visualization results are obtained:
master code
import tensorflow as tf # Create the TensorFlow framework def Create_Tensorflow(): # Chart (static) a = (2) # Data 1 (tensor) b = (6) # Data 2 (tensor) c = a + b # Operations (nodes) # Sessions (executive) with () as sess: print('c=', (c)) # Visualization ("C:\\Users\\Administrator\\Desktop\\summary", graph=) # View Default Chart View_Graph(a, b, c, sess) # View Figure def View_Graph(a, b, c, sess): # Method I: Invocation method default = tf.get_default_graph() print('default:', default) # Method 2: View Properties # View node properties print('Attributes of a:', ) print('Attributes of c:', ) # View session properties print('Graph properties for session sess:', ) # Customized charts def Create_myGraph(): # 1 Create a customized diagram new_graph = () print(new_graph) # 2 Create static graphs (tensor and nodes) with new_graph.as_default(): a = (10) b = (20) c = a + b print(c) # 3 Open dialog (running) with (graph=new_graph) as sess: print('c=', (c)) # 4 Viewing Customized Diagrams View_Graph(a, b, c, sess) if __name__ == '__main__': # Create the TensorFlow framework Create_Tensorflow() # Create custom diagrams Create_myGraph()
Above is the TensorFlow visualization tool TensorBoard default graph and custom graph of the details, more information about TensorFlow visualization TensorBoard tool please pay attention to my other related articles!