无法使用 TensorFlow 0.7.1 在 TensorBoard 中可视化 Inception v3 模型 [英] Unable to visualize Inception v3 model in TensorBoard with TensorFlow 0.7.1

查看:32
本文介绍了无法使用 TensorFlow 0.7.1 在 TensorBoard 中可视化 Inception v3 模型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 TensorFlow 0.7.1 中的 TensorBoard 来可视化 Google 的 Inception v3 模型,但我无法这样做.TensorBoard Graph 选项卡随着语句停止

I'm attempting to visualize Google's Inception v3 model using TensorBoard in TensorFlow 0.7.1 and am unable to do so. The TensorBoard Graph tab stalls with the statement

数据:读取graph.pbtxt

Data : Reading graph.pbtxt

我下载了一个未解压的 inception v3模型.图 protobuffer 位于 /tmp/imagenet/classify_image_graph_def.pb.

I downloaded an un-Tarred the inception v3 model. The graph protobuffer is in /tmp/imagenet/classify_image_graph_def.pb.

这是我转储模型的代码:

Here's my code to dump the model:

import os
import os.path
import tensorflow as tf
from tensorflow.python.platform import gfile

INCEPTION_LOG_DIR = '/tmp/inception_v3_log'

if not os.path.exists(INCEPTION_LOG_DIR):
    os.makedirs(INCEPTION_LOG_DIR)
with tf.Session() as sess:
    model_filename = '/tmp/imagenet/classify_image_graph_def.pb'
    with gfile.FastGFile(model_filename, 'rb') as f:
        graph_def = tf.GraphDef()
        graph_def.ParseFromString(f.read())
        _ = tf.import_graph_def(graph_def, name='')
    writer = tf.train.SummaryWriter(INCEPTION_LOG_DIR, graph_def)
    writer.close()

这会转储一个名为 events.out.tfevents.1456423256.[hostname](与图形原型缓冲区大小相同)的 91 MB 文件,因此图形似乎在某处.

This dumps a 91 MB file called events.out.tfevents.1456423256.[hostname] (same size as the graph protobuffer) so it seems that the graph is in there somewhere.

我按如下方式运行 TensorBoard:

I ran TensorBoard as follows:

tensorboard --logdir /tmp/inception_v3_log

这导致了前面提到的图表页面上挂起的加载栏.

Which results in the aforementioned hung loading bar on the Graph page.

Chrome JavaScript 控制台产生此错误:

The Chrome JavaScript console yields this error:

未捕获的类型错误:无法读取未定义的属性0"

Uncaught TypeError: Cannot read property '0' of undefined

我认为这与图表丢失的事实有关.

which I assume is related to the fact that the graph is missing.

我已经在 OS X 10.11.3 上的 Chrome 48.0.2564.116(64 位)上尝试了这个,两者都使用 TensorFlow 0.7.1 for Python 3 构建,使用 Bazel 和 TensorFlow 0.7.1 for Python 2 构建,通过 pip 与确切的相同的结果.

I've tried this with Chrome 48.0.2564.116 (64-bit) on OS X 10.11.3 both with TensorFlow 0.7.1 for Python 3 built using Bazel and TensorFlow 0.7.1 for Python 2 installed via pip with the exact same results.

我还验证了我可以可视化使用 mnist_with_summaries 示例,因此这是 Inception 模型特有的问题.

I also verified that I can visualize the graph generated with the mnist_with_summaries example, so this is an issue specifically with the Inception model.

推荐答案

使用此代码:这对我有用:

Use this code: This works for me:

import tensorflow as tf
from tensorflow.python.platform import gfile
with tf.Session() as sess:
    model_filename ='YouGraphNameWithPath.pb'
    with gfile.FastGFile(model_filename, 'rb') as f:
        graph_def = tf.GraphDef()
        graph_def.ParseFromString(f.read())
        g_in = tf.import_graph_def(graph_def)
LOGDIR='PathWhereSummaryWillBeSaved'
train_writer = tf.summary.FileWriter(LOGDIR)
train_writer.add_graph(sess.graph)

这篇关于无法使用 TensorFlow 0.7.1 在 TensorBoard 中可视化 Inception v3 模型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆