1、下载mnist数据与预处理
下载好的数据集中有60000个训练样本和10000个测试样本。样本的xs为28x28的图像矩阵,标签ys为0~9。现将图像全部展开为长向量(784维),则mnist.train.images
是一个形状为 [60000, 784]
的张量,第一个维度数字用来索引图片,第二个维度数字用来索引每张图片中的像素点;将标签写为"one-hot vectors", 一个one-hot向量除了某一位的数字是1以外其余各维度数字都是0,故mnist.train.labels
是一个 [60000, 10]
的数字矩阵
# Copyright 2015 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specifi