另外一种读入mnist数据集的方式 好像更加常用一些
可以自动从mnist官网下载压缩包 然后提取里面的内容,保存在mnist结构体里面
遇到了两个问题:
1)URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:847)>
解决方法已经注释出来了
2)label的编码方式采用的是onehot;也就是说label是一个长度为10的向量,只有一个位置为1,其他位置为0,为1的位置对应就是手写数字的值0~9 这个和上一篇的label不一样 上一篇label就是输出0~9的数值
后面输出了一些图片及其label
如果把onehot改为False,就和上一篇的label一样了
代码是python3了 python2倒计时。。。。
from tensorflow.examples.tutorials.mnist import input_data
import ssl
import matplotlib.pyplot as plt
import numpy as np
ssl._create_default_https_context = ssl._create_unverified_context
# 这一句是因为一直报了一个URL的错误才加入的
# URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:847)>
# 根据https://www.cnblogs.com/wsygdb/p/7902956.html 加入这句话就解决了
mnist = input_data.read_data_sets('./data/',one_hot=True)
# 这里要注意的是 这