首先我们来介绍一下mnist数据集
MNIST数据集由Yann LeCun搜集,是一个大型的手写体数字数据库,通常用于训练各种图像处理系统,也被广泛用于机器学习领域的训练和测试。MNIST数字文字识别数据集数据量不会太多,而且是单色的图像,较简单,适合深度学习初学者练习建立模型、训练、预测。MNIST数据库中的图像集是NIST(National Institute of Standards and Technology)的两个数据库的组合:专用数据库1和特殊数据库3。数据集是有250人手写数字组成,一半是高中生,一半是美国人口普查局。
MNIST数据集共有训练数据60000项、测试数据10000项。每张图像的大小为28*28(像素),每张图像都为灰度图像,位深度为8(灰度图像是0-255)。
模型(一)
这个模型是一个比较简单的全连接神经网络,我设置了两个全连接层,矩阵规格的变化如下:
( [ None , 28 * 28 ] * [ 28 * 28 , 10 ] + [ 10 ] ) * [ 10 , 10 ] + [ 10 ]
其中第一个全连接层的权重为[ 28 * 28 , 10 ] ,偏置为 [ 10 ]
其中第二个全连接层的权重为[ 10 , 10 ] ,偏置为 [ 10 ]
import os
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
import tensorflow as tf
from tensorflow.examples.tutorials.mnist import input_data
def full_connect():
# 用全连接对手写数字进行识别
# 1、准备数据
mnist = input_data.read_data_sets("data", one_hot=True)
x = tf.placeholder(dtype=tf.float32,shape=[None,28*28])
y_true = tf.placeholder(dtype=tf.float32,shape=[None,10])
# 2、构建模型
Weights_1 = tf.Variable(initial_value=tf.random_normal(shape=[784,10]))
bias_1 = tf.Variable(initial_value=tf.random_normal(shape=[10]))
Weights_2 = tf.Variable(initial_value=tf.random_normal(shape=[10,10]))
bias_2 = tf.Variable(initial_value=tf.random_normal(shape=[10]))
middle = tf.

最低0.47元/天 解锁文章
全连接神经网络识别mnist数据集&spm=1001.2101.3001.5002&articleId=124292109&d=1&t=3&u=832234aa4ffc45a186043123c997b681)
792

被折叠的 条评论
为什么被折叠?



