addlayer添加神经网络层
def addlayer(inputs,insize,outsize,activity_function = None):
weights = tf.Variable(tf.random_normal([insize,outsize]))
biases = tf.Variable(tf.zeros([1,outsize])+0.1)
totle = tf.multiply(weights,inputs)+ biase
if actiactivity_function is None:
outputs = totle
else:
outputs = activity_function(totle)
return outputs
写一个添加网络层的函数,方便后面随便添加网络的层数。
insize,outsize 输入和输出的大小
activity_function 激活函数