现放图片,代码在下面
运行:
import tensorflow as tf
from tensorflow.examples.tutorials.mnist import input_data #载入数据集
#载入数据集 one_hot
mnist = input_data.read_data_sets('./datas/MNIST_data',one_hot=True)
#每个批次的大小,一次放一个批次的图片到神经网络
batch_size = 100
n_batch = mnist.train.num_examples//batch_size #n个批次=数据大小整除批次大小
#定义两个占位符
x = tf.placeholder(tf.float32,[None,784]) #行,一行784列,一张图片
y = tf.placeholder(tf.float32,[None,10])
#创建一个简单的神经网络
W = tf.Variable(tf.zeros([784,10]))
b = tf.Variable(tf.zeros([10]))
prediction = tf.nn.softmax(tf.matmul(x,W)+b)