实验一:可视化之Graph
对mnist_deep.py代码做适当修改,使用tensorboard查看CNN的整体运行框架图。
def add_layer(inputs, in_size, out_size, activation_function=None):
# add one more layer and return the output of this layer
with tf.name_scope('layer'):
with tf.name_scope('weights'):
Weights =weight_variable([in_size,out_size])
with tf.name_scope('biases'):
biases = bias_variable([1,out_size])
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)
return outputs
#loss函数,交叉熵
with tf.name_scope('loss'):
cross_entropy=tf.reduce_mean(-tf.reduce_sum(y_*tf.log(prediction),