这几天学了卷积
跟搞ACM学的卷积不是一个东西吧
我反正没感到一点相关
准确率97.2%,还不错,可以接受
上代码吧:
import tensorflow as tf
from tensorflow.examples.tutorials.mnist import input_data
mnist = input_data.read_data_sets('MNIST_data', one_hot=True)
def compute_accuracy(v_xs, v_ys):
global prediction
y_pre = sess.run(prediction, feed_dict={xs: v_xs, keep_prob: 1})
correct_prediction = tf.equal(tf.argmax(y_pre,1), tf.argmax(v_ys,1))
accuracy = tf.reduce_mean(tf.cast(correct_prediction, tf.float32))
result = sess.run(accuracy, feed_dict={xs: v_xs, ys: v_ys, keep_prob: 1})
return result
def W(shape):
initial = tf.truncated_normal(shape, stddev=0.1)
return tf.Variable(initial)
def Conv2d(x,y):
return tf.nn.conv2d(x, y, strides=[1, 1, 1, 1], padding='SAME')
def Pool(x):
return tf.nn.max_pool(x, ksize=[1,2,2,1], strides