There is an error:
File "tensorflow/models/image/mnist/convolutional.py", line 59, in extract_data
bytestream.read(16)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/gzip.py", line 268, in read
self._read(readsize)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/gzip.py", line 303, in _read
self._read_gzip_header()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/gzip.py", line 197, in _read_gzip_header
raise IOError, 'Not a gzipped file'
解决方法:
The code attempts to download the data files from the MNIST web site, and assumes it’s properly downloaded if the file is present locally on your system. You might have a corrupted file, in which case deleting it and retrying might help. Otherwise, try to get the data via your browser directly from:
下载后替换原来的文件就没有问题了
http://yann.lecun.com/exdb/mnist/train-images-idx3-ubyte.gz http://yann.lecun.com/exdb/mnist/train-labels-idx1-ubyte.gz http://yann.lecun.com/exdb/mnist/t10k-images-idx3-ubyte.gz http://yann.lecun.com/exdb/mnist/t10k-labels-idx1-ubyte.gz
在学习神经网络时,经常会用到MNIST数据集,使用Tensorflow导入数据集的时候,使用以下方法有时会出现警告
from tensorflow.examples.tutorials.mnist import input_data
import tensorflow as tf
mnist = input_data.read_data_sets("MNIST_data/", one_hot=True)
解决方法是修改为以下代码
from tensorflow.contrib.learn.python.learn.datasets.mnist import read_data_sets
import tensorflow as tf
mnist = read_data_sets("MNIST_data/", one_hot=True)
成功导入结果
Extracting MNIST_data/train-images-idx3-ubyte.gz
Extracting MNIST_data/train-labels-idx1-ubyte.gz
Extracting MNIST_data/t10k-images-idx3-ubyte.gz
Extracting MNIST_data/t10k-labels-idx1-ubyte.gz
参考:https://blog.csdn.net/Julialove102123/article/details/70226249/ https://blog.csdn.net/qq1440643730/article/details/104122320