2019-10-26 09:41:34.625499: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library 'libcuda.so.1'; dlerror: libcuda.so.1: cannot open shared object file: No such file or directory
2019-10-26 09:41:34.625525: E tensorflow/stream_executor/cuda/cuda_driver.cc:318] failed call to cuInit: UNKNOWN ERROR (303)
2019-10-26 09:41:34.625538: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:156] kernel driver does not appear to be running on this host (lixinming-Lenovo-Product): /proc/driver/nvidia/version does not exist
2019-10-26 09:41:34.625714: I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
2019-10-26 09:41:34.650504: I tensorflow/core/platform/profile_utils/cpu_utils.cc:94] CPU Frequency: 3492910000 Hz
2019-10-26 09:41:34.650929: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x540e960 initialized for platform Host (this does not guarantee that XLA will be used). Devices:
2019-10-26 09:41:34.650980: I tensorflow/compiler/xla/service/service.cc:176] StreamExecutor device (0): Host, Default Vers
一直纠结于没有出现http:~,尝试通过各种办法解决。annacuda、libcuba阿,等等很多。
最后回顾了以下tensorboard的运行状况。
发现是自己没有操作好。乌版图中,应该先在终端输入**tensorboard --logdir=文件路径**
在终端中会有一个http~,打开连接即可
Tensorboard可以记录与展示以下数据形式:
(1)标量Scalars
(2)图片Images
(3)音频Audio
(4)计算图Graph
(5)数据分布Distribution
(6)直方图Histograms
(7)嵌入向量Embeddings
1)首先肯定是先建立一个graph,你想从这个graph中获取某些数据的信息
(2)确定要在graph中的哪些节点放置summary operations以记录信息
使用tf.summary.scalar记录标量
使用tf.summary.histogram记录数据的直方图
使用tf.summary.distribution记录数据的分布图
使用tf.summary.image记录图像数据
….
(3)operations并不会去真的执行计算,除非你告诉他们需要去run,或者它被其他的需要run的operation所依赖。而我们上一步创建的这些summary operations其实并不被其他节点依赖,因此,我们需要特地去运行所有的summary节点。但是呢,一份程序下来可能有超多这样的summary 节点,要手动一个一个去启动自然是及其繁琐的,因此我们可以使用
去将所有summary节点合并成一个节点,只要运行这个节点,就能产生所有我们之前设置的summary data。
(4)使用**
**r将运行后输出的数据都保存到本地磁盘中
(5)运行整个程序,并在命令行输入运行tensorboard的指令,之后打开web端可查看可视化的结果
原文代码如下:
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'):
with tf.name_scope('Weights'):
Weights = tf.Variable(tf.random.normal([in_size,out_size]),name='W')
tf.compat.v1.summary.histogram(layer_name+'/weights',Weights)
with tf.name_scope('biases'):
biases = tf.Variable(tf.zeros([1,out_size])+0.1,name='b')
tf.compat.v1.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.compat.v1.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.compat.v1.placeholder(tf.float32,[None,1],name = 'x_input')
ys = tf.compat.v1.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 prediction and real data
with tf.name_scope('loss'):
loss = tf.reduce_mean(tf.reduce_sum(tf.square(ys-prediction),reduction_indices=[1]))
tf.compat.v1.summary.scalar('loss',loss)
with tf.name_scope('train'):
train_step = tf.compat.v1.train.GradientDescentOptimizer(0.1).minimize(loss)
sess = tf.compat.v1.Session()
merged=tf.compat.v1.summary.merge_all()#将所有summary节点合并成一个节点,只要运行这个节点,
#就能产生所有我们之前设置的summary data
writer = tf.compat.v1.summary.FileWriter("/home/lixinming/PycharmProjects/",sess.graph)
# important step
sess.run(tf.compat.v1.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)