Tensorboard错误 - NameError:name' tensorboard'没有定义

时间:2017-02-28 22:34:41

标签: tensorboard

我现在正在学习张量流,但无法让张量板工作。我尝试了下面的简单程序没有运气。该程序在我使用tensorboard代码之前工作,但是当我使用tensorboard代码时,我得到以下错误:

NameError: name 'tensorboard' is not defined

请提供任何帮助。

import tensorflow as tf


a = tf.constant(5, name="input_a")
b = tf.constant(3, name="input_a")
c = tf.multiply(a,b, name="mul_c")
d = tf.add(a,b, name="add_d")
e = tf.add(c,d, name="add_e")

sess = tf.Session()
sess.run(e)
output = sess.run(e)

writer = tf.summary.FileWriter('/tmp/newtest', graph=sess.graph)

print(sess.run(e))

tensorboard --logdir /tmp/newtest

1 个答案:

答案 0 :(得分:0)

我相信这已经回答过了,但是,为了对我所做的事情进行抽样,我希望它可以帮助你或其他人。

这仅仅涵盖了触发&amp ;;的结束开销。显示张量板。

import subprocess
import webbrowser
import time

logLocation = 'tflearn_logs'

print("\r\nWould you like to see the visual results (y/N)? ", end='', flush=True)
answer = input()
if answer.strip().lower() == "y":
    port = str(8018)
    print("Starting Tensorboard to visualize... ")
    process = subprocess.Popen(['tensorboard', "--logdir='" + logLocation + "'", '--port=' + port])

    # Wait for a few seconds, give the tensorboard a headstart
    time.sleep(5)

    print("Opening Tensorboard webpage... ")
    url = 'http://127.0.0.1:' + port + '/'
    # Path differs per OS (Windows, Linux, iOS)
    chrome_path = 'C:/Program Files (x86)/Google/Chrome/Application/chrome.exe %s'
    webbrowser.get(chrome_path).open(url) 

print("Press enter to quit... ", end='', flush=True)
answer = input()
if process is not None:
    process.kill()