请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

tensorboard启动后访问不到图形化界面

老师您好:,请问下启动tensorboard后,访问结果如下:

https://img1.sycdn.imooc.com//szimg/5afd12630001635510000538.jpg

准备工作:log确实已经生成了,https://img1.sycdn.imooc.com//szimg/5afd128600014ef406430102.jpg

正在回答 回答被采纳积分+3

1回答

Erik_Song 2018-05-17 13:44:09

代码贴一下吧

0 回复 有任何疑惑可以回复我~
  • 提问者 慕粉3504785 #1
    # -*- coding: UTF-8 -*-
    
    # 引入tensorflow
    import tensorflow as tf
    
    # 构造图(Graph)的结构
    # 用一个线性方程的例子 y = W * x + b
    W = tf.Variable(2.0, dtype=tf.float32, name="Weight")  # 权重
    b = tf.Variable(1.0, dtype=tf.float32, name="Bias")  # 偏差
    x = tf.placeholder(dtype=tf.float32, name="Input")  # 输入
    with tf.name_scope("Output"):      # 输出的命名空间
        y = W * x + b    # 输出
    
    # const = tf.constant(2.0)  # 不需要初始化
    
    # 定义保存日志的路径
    path = "./log"
    
    # 创建用于初始化所有变量(Variable)的操作
    # 如果定义了变量,但没有初始化的操作,会报错
    init = tf.global_variables_initializer()
    
    # 创建 Session(会话)
    with tf.Session() as sess:
        sess.run(init)  # 初始化变量
        writer = tf.summary.FileWriter(path, sess.graph)
        result = sess.run(y, {x: 3.0})  # 为 x 赋值 3
        print("y = W * x + b,值为 {}".format(result))  # 打印 y = W * x + b 的值,就是 7
        writer.close()
    回复 有任何疑惑可以回复我~ 2018-05-17 17:18:50
问题已解决,确定采纳
还有疑问,暂不采纳
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号