#下载数据集
from tensorflow.examples.tutorials.mnist import input_data
mnist = input_data.read_data_sets("MNIST_data",one_hot = True)
#引入tensorflow
import tensorflow as tf
#建立session对象
sess = tf.InteractiveSession()
#占位符(图像和标签)
x = tf.placeholder(tf.float32, shape=[None, 784])
y_ = tf.placeholder(tf.float32, shape=[None, 10])
#权重函数
def weight_variable(shape):
initial = tf.truncated_normal(shape,stddev = 0.1)
return tf.Variable(initial)
#偏置函数
def bias_variable(shape):
initial = tf.constant(0.1,shape = shape)
return tf.Variable(initial)
#卷积函数
def conv2d(x,W):
return tf.nn.conv2d(x, W, strides = [1,1,1,1], padding = "SAME")
#池化函数
def max_pool_2x2(x):
return tf.nn.max_pool(x, ksize = [
用卷积神经网络对mnist进行数字识别程序(tensorflow)
最新推荐文章于 2024-08-02 12:58:05 发布