1 2 3 4 5 6 7 8 9 10 11 12
| import tensorflow as tf
def add_layer(inputs,in_size,out_size,activation_function = None): Weights = tf.Variable(tf.random_normal([in_size,out_size])) biases = tf.Variable(tf.zeros([1,out_size]) + 0.1) Wx_plus_b = tf.matmul(inputs,Weights) + biases if activation_function is None: outputs = Wx_plus_b else: outputs = activation_function(Wx_plus_b) return outputs
|