Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Analyze a tensorflow graph or a .pb file on Tensorboard

I have been following github repository for "Tensorflow on Android".

  1. I was able to build the code using bazel and then import the Android project to Android Studio, as mentioned here.
  2. As you can see here, after building the APK, using Android Studio, the Model files/Graphs are included in the tensorflow/examples/android/assets
  3. By default, tensorflow_inception_graph.pb and imagenet_comp_graph_label_strings.txt are included, from inception5 file which is downloaded while the APK is built.

What's the issue?

  1. I have a retrained graph (InceptionV3 model, mentioned in tensorflow/examples/image_retraining/retrain.py), which I was able to place in the assets folder in android directory and generate a working APK.
  2. Inference time while I was using the default graph or .pb file was ~500ms and with my retrained.pb or graph it is ~1400ms.(tested on OnePlus3T device)

Please help me understand

  1. How to analyze the default tensorflow_inception_graph.pb on Tensorboard
like image 656
Subhash_Reddy Avatar asked Apr 12 '17 16:04

Subhash_Reddy


People also ask

How do you analyze a TensorBoard?

Tensorboard works by reading the event files which is where Tensorflow writes the summary data (the data to be visualized). It usually comes installed with Tensorflow and to execute it simply run the following command: tensorboard --logdir=[dir] where [dir] is the event files location.

How do you read a TensorBoard histogram?

Simply speaking, if the possible values are in a range of 0.. 9 and you see a spike of amount 10 on the value 0 , this means that 10 inputs assume the value 0 ; in contrast, if the histogram shows a plateau of 1 for all values of 0.. 9 , it means that for 10 inputs, each possible value 0.. 9 occurs exactly once.


1 Answers

Last May they have introduced a helper script called import_pb_to_tensorboard to do just that.

usage: import_pb_to_tensorboard.py [-h] [--model_dir MODEL_DIR]
                                   [--log_dir LOG_DIR]

optional arguments:
  -h, --help            show this help message and exit
  --model_dir MODEL_DIR
                        The location of the protobuf ('pb') model to
                        visualize.
  --log_dir LOG_DIR     The location for the Tensorboard log to begin
                        visualization from.

Note that currently, the version in master seems to have received more love than the one present in the latest 1.2.1 distribution of tensorflow, so I would suggest to use this one.

like image 138
P-Gn Avatar answered Sep 22 '22 12:09

P-Gn