* Clarify and correct Android Sections Build Tools version updated to latest version shipping with Android Studio. Added some comments to clarify both this and NDK Level details that have been causing confusion. * Update Build Tools Version Android studio uses 25.0.2 now (I think) and complains about incorrect bulid tools version in gradle. This fixes it. Not sure if this is unique to my android studio though because I have latest version? * Requested changes to WORKSPACE for Android Clarification of comments to the android section at the top. Comments added to avoid common confusion. * Update Dockerfile.android to clarify build tools. I don't understand this dockerfile too much but I gather that this will download and use the correct build_tools_version regardless? Nonetheless, updated to 25.0.2 as a minimum and added a comment to assist troubleshooters in the future. * Update build_tools_version and add comment Added comment to clarify build_tools_version updates and changed it to 25.0.2 * Update WORKSPACE * Update WORKSPACE * Update Dockerfile.android * Update WORKSPACE * Updated for "the", lines and line wrapping * Create import_pb_to_tensorboard.py In response to issue #8851, a quick tool to put a .pb model into tensorboard for visualization until a more friendly means appears. * Fix issue number * Improve formatting and style guideline adherence Action the suggested changes * Fix code on behalf of user * Add copyright and __future__ imports * Typo * Fix lint error * Change tab to space and minor MD formatting.
This commit is contained in:
parent
74e9ccc7d5
commit
0627928fb4
44
tensorflow/python/tools/import_pb_to_tensorboard.py
Normal file
44
tensorflow/python/tools/import_pb_to_tensorboard.py
Normal file
@ -0,0 +1,44 @@
|
||||
# Copyright 2017 The TensorFlow Authors. All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
# ================================
|
||||
|
||||
from __future__ import absolute_import
|
||||
from __future__ import division
|
||||
from __future__ import print_function
|
||||
|
||||
import tensorflow as tf
|
||||
|
||||
|
||||
def import_to_tensorboard(model_dir, log_dir):
|
||||
"""View an imported protobuf model (`.pb` file) as a graph in Tensorboard.
|
||||
|
||||
Args:
|
||||
model_dir: The location of the protobuf (`pb`) model to visualize
|
||||
log_dir: The location for the Tensorboard log to begin visualisation from.
|
||||
|
||||
Usage:
|
||||
Call this function with your model location and desired log directory.
|
||||
Launch Tensorboard by pointing it to the log directory.
|
||||
View your imported `.pb` model as a graph.
|
||||
"""
|
||||
with tf.Session(graph=tf.Graph()) as sess:
|
||||
with tf.gfile.FastGFile(model_dir, 'rb') as f:
|
||||
graph_def = tf.GraphDef()
|
||||
graph_def.ParseFromString(f.read())
|
||||
g_in = tf.import_graph_def(graph_def)
|
||||
|
||||
pb_visual_writer = tf.summary.FileWriter(log_dir)
|
||||
pb_visual_writer.add_graph(sess.graph)
|
||||
print("Model Imported. Visualize by running: "
|
||||
"> tensorboard --logdir={}".format(log_dir))
|
Loading…
Reference in New Issue
Block a user