| 11 | |
| 12 | |
| 13 | def add_layer(inputs, in_size, out_size, activation_function=None): |
| 14 | # add one more layer and return the output of this layer |
| 15 | with tf.name_scope('layer'): |
| 16 | with tf.name_scope('weights'): |
| 17 | Weights = tf.Variable(tf.random_normal([in_size, out_size]), name='W') |
| 18 | with tf.name_scope('biases'): |
| 19 | biases = tf.Variable(tf.zeros([1, out_size]) + 0.1, name='b') |
| 20 | with tf.name_scope('Wx_plus_b'): |
| 21 | Wx_plus_b = tf.add(tf.matmul(inputs, Weights), biases) |
| 22 | if activation_function is None: |
| 23 | outputs = Wx_plus_b |
| 24 | else: |
| 25 | outputs = activation_function(Wx_plus_b, ) |
| 26 | return outputs |
| 27 | |
| 28 | |
| 29 | # define placeholder for inputs to network |