Determine the names of input and output nodes

Skip this step if you are able to determine the names of the input and output nodes from the provider of your model or the training code. However, this step also demonstrates how to visualize the computational graph in a neural network model. This well help you to understand what will be executed at runtime and how the various transform_graph operations affect the structure of the model in practice.

The simplest way to visualize graphs is to use TensorBoard. To install TensorBoard, enter the following on the command line:

pip install tensorboard
tensorboard --logdir=/tmp/tensorboard

Use the script provided in the TensorFlow source distribution to import model (.pb) files to TensorBoard by entering the following on the command line:

python tensorflow/python/tools/import_pb_to_tensorboard.py --model_dir resnetv1_50.pb --log_dir /tmp/tensorboard

Do not let the name of the argument model_dir confuse you. A .pb file is an acceptable target.

Important: if you repeat this command for importing multiple models, empty the /tmp/tensorboard directory after each import to prevent confusion.

In a browser, navigate to http://localhost:6006/ and select the GRAPHS tab to see the model's graph. If it is collapsed under a single node, as shown in this image, use the expand control until you get to the actual operations.

In this network we can see that Placeholder is the only input node and Reshape_1 is the output node. To get their full names, select them and look at the details box on the right, as this image shows.

details box for input and output nodes displaying information

Here, the name of the input node is import/Placeholder and the output node is import/resnet_v1_50/predictions/Reshape_1. 

The details box also shows that this model has been trained with the standard 224x224x3 input size which is typical for a ResNet architecture. The transform_graph tool assumes the import namespace, so these are simplified to:

  • Input name: Placeholder.
  • Input dimensions: ?x224x224x3.
  • Output name: resnet_v1_50/predictions/Reshape_1.
Prerequisites 32-bit model