import tensorflow as tf
import numpy as np
def add_layer(inputs, in_size, out_size, n_layer, activation_function=None):
layer_name = 'layer%s' % n_layer
with tf.name_scope("layer"):
with tf.name_scope("weight"):
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.matmul(inputs, Weights)+biases
if activation_function == None:
outputs = Wx_plus_b
else:
outputs = activation_function(Wx_plus_b)
tf.summary.histogram(layer_name+&#
TensorBoard可视化命令
最新推荐文章于 2024-04-25 10:15:28 发布