SoFunction
Updated on 2025-03-01

Tensorflow uses the model file and use the tensorboard to view its model graph Graph method

Google provides a tool, TensorBoard, which analyzes various data you summarize during training in a graphical way, including Graph structures.

So we can simply write a few lines of Python, load Graph, and output Graph structure data only in logdir, and view its graph structure.

Execute the following code to save the data flow graph as a picture, and generate the file in the directory F:/tensorflow/graph.-PC

import tensorflow as tf
from  import gfile
 
graph = tf.get_default_graph()
graphdef = graph.as_graph_def()
_ = .import_meta_graph("")
summary_write = ("./" , graph)
summary_write.close()

Enable tensorboard

The python development environment I use is Anaconda

(1) Open Anaconda Prompt, enter activate tensorflow to enter the tensorflow environment;

(2) Turn on the tensorboard and enter the following command

tensorboard --logdir=F://tensorflow//graph

The parameter in logdir is the path that saves the graph in the code. If written as a single slash, the tensorboard can be opened, but the graph is displayed "No graph definition files were found" and does not display the graph. The path parameter is changed to a double slash.

3. Use tensorboard to view the generated graph

(1) Open http://127.0.0.1:6006/ in Google Chrome and the orange interface will be displayed;

(2) Select graphs in the tab of the first line to see the results.

The above article "The Graph" is the entire content that the editor has shared with you through the model file and using tensorboard to view its model graph. I hope it can give you a reference and I hope you can support me more.