| 13 | mnist = input_data.read_data_sets('MNIST_data', one_hot=True) |
| 14 | |
| 15 | def add_layer(inputs, in_size, out_size, activation_function=None,): |
| 16 | # add one more layer and return the output of this layer |
| 17 | Weights = tf.Variable(tf.random_normal([in_size, out_size])) |
| 18 | biases = tf.Variable(tf.zeros([1, out_size]) + 0.1,) |
| 19 | Wx_plus_b = tf.matmul(inputs, Weights) + biases |
| 20 | if activation_function is None: |
| 21 | outputs = Wx_plus_b |
| 22 | else: |
| 23 | outputs = activation_function(Wx_plus_b,) |
| 24 | return outputs |
| 25 | |
| 26 | def compute_accuracy(v_xs, v_ys): |
| 27 | global prediction |