tensorboard可视化出现No dashboards are active for the current data set错误的解决和其它情况

本文介绍了在使用TensorFlow1.5时遇到TensorBoard显示"No dashboards are active for the current data set"错误的两种情况及解决方案。第一种情况是路径配置错误,只需指定正确的logdir。第二种情况可能由TensorFlow版本引起,建议使用Python3.5和TensorFlow1.5,并提供测试代码确保配置正确。参照提供的资源链接可以解决numpy版本不匹配问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

第一种情况,路径不对

测试代码

import tensorflow as tf

# 定义一个简单的计算图,实现向量加法的操作。
input1 = tf.constant([1.0, 2.0, 3.0], name = 'input1')
input2 = tf.Variable(tf.random_uniform([3]), name = 'input2')
output = tf.add_n([input1, input2], name = 'add')

# 生成一个写日志的writer,并将当前的tensorflow计算图写入日志。
# tensorflow提供了多种写日志文件的API
writer = tf.summary.FileWriter('G:/tf', tf.get_default_graph())
writer.close()

在G盘下会生成tf文件夹,只需要

只需要如下就可以。

 

第二种情况是因为tensorflow版本的问题,只有graphs显示,其他的显示没有

第二种情况

如上图所示只出现graphs页面,其他页面还是错误(原因可能是tensorflow版本问题【建议python3.5+tensorflow1.5】,还有可能就是代码里面没有设置相关的参数,建议用下面的代码测试一下(第一种情况下代码的问题)

已测试在python3,.5+tensorflow1.5下可行

解决方案:参考https://blog.youkuaiyun.com/baidu_36669549/article/details/80174392

首先编写测试代码生成模型:

 
import tensorflow as tf
import numpy as np
 
 
def add_layer(inputs, in_size, out_size, n_layer, activation_function=None):
    # add one more layer and return the output of this layer
    layer_name = 'layer%s' % n_layer
    with tf.name_scope(layer_name):
        with tf.name_scope('weights'):
            Weights = tf.Variable(tf.random_normal([in_size, out_size]), name='W')
            tf.summary.histogram(layer_name + '/weights', Weights)
        with tf.name_scope('biases'):
            biases = tf.Variable(tf.zeros([1, out_size]) + 0.1, name='b')
            tf.summary.histogram(layer_name + '/biases', biases)
        with tf.name_scope('Wx_plus_b'):
            Wx_plus_b = tf.add(tf.matmul(inputs, Weights), biases)
        if activation_function is None:
            outputs = Wx_plus_b
        else:
            outputs = activation_function(Wx_plus_b, )
        tf.summary.histogram(layer_name + '/outputs', outputs)
        return outputs
 
 
# Make up some real data
x_data = np.linspace(-1, 1, 300)[:, np.newaxis]
noise = np.random.normal(0, 0.05, x_data.shape)
y_data = np.square(x_data) - 0.5 + noise
 
# define placeholder for inputs to network
with tf.name_scope('inputs'):
    xs = tf.placeholder(tf.float32, [None, 1], name='x_input')
    ys = tf.placeholder(tf.float32, [None, 1], name='y_input')
 
# add hidden layer
l1 = add_layer(xs, 1, 10, n_layer=1, activation_function=tf.nn.relu)
# add output layer
prediction = add_layer(l1, 10, 1, n_layer=2, activation_function=None)
 
# the error between prediciton and real data
with tf.name_scope('loss'):
    loss = tf.reduce_mean(tf.reduce_sum(tf.square(ys - prediction),
                                        reduction_indices=[1]))
    tf.summary.scalar('loss', loss)
 
with tf.name_scope('train'):
    train_step = tf.train.GradientDescentOptimizer(0.1).minimize(loss)
 
sess = tf.Session()
merged = tf.summary.merge_all()
writer = tf.summary.FileWriter("E://my_python_pro", sess.graph)
# important step
sess.run(tf.global_variables_initializer())
 
for i in range(1000):
    sess.run(train_step, feed_dict={xs: x_data, ys: y_data})
    if i % 50 == 0:
        result = sess.run(merged,
                          feed_dict={xs: x_data, ys: y_data})
        writer.add_summary(result, i)

然后会在E盘生成my_python_pro文件夹

打开tensorflow环境终端,切换到E盘(一般切换到生成文件的上一层目录)

然后输入 tensorboard --logdir=E://my_python_pro

将网址复制到谷歌浏览器中,ok

 

总结错误:

1,在安装tensorflow1.5,测试安装是否成功,import tensorflow   可能会出现错误(参考https://blog.youkuaiyun.com/mao123_4zxc/article/details/99717601),如下出现

说明numpy版本不匹配,所以先卸载,然后 pip install numpy==1..16

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值