导入相关包
import numpy as np
import tensorflow as tf
import matplotlib.pyplot as plt
# tensorflow自带的一些数据集
from tensorflow.examples.tutorials.mnist import input_data
加载数据集
在该目录下,建立一个空文件夹data
,加载mnist数据集时,会自动从网上下载
print('Download and Extract MNIST dataset')
mnist = input_data.read_data_sets('data/', one_hot=True)
print('type of "mnist" is %s' % (type(mnist)))
print('number of train data is %d' % (mnist.train.num_examples))
print('number of test data is %d' % (mnist.test.num_examples))
mnist数据集的描述信息
trainimg = mnist.train.images