我试图使用mnist数据集使用Tensorflow创建模型。
我已经正确安装了Tensorflow,然后当我尝试使用命令创建模型时。

python convolutional.py


我在控制台上收到一条错误消息:

Successfully downloaded train-images-idx3-ubyte.gz 9912422 bytes.
Successfully downloaded train-labels-idx1-ubyte.gz 28881 bytes.
Successfully downloaded t10k-images-idx3-ubyte.gz 1648877 bytes.
Successfully downloaded t10k-labels-idx1-ubyte.gz 4542 bytes.
Extracting data/train-images-idx3-ubyte.gz
Traceback (most recent call last):
  File "convolutional.py", line 316, in <module>
    tf.app.run()
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/platform/default/_app.py", line 30, in run
    sys.exit(main(sys.argv))
  File "convolutional.py", line 128, in main
    train_data = extract_data(train_data_filename, 60000)
  File "convolutional.py", line 75, in extract_data
    buf = bytestream.read(IMAGE_SIZE * IMAGE_SIZE * num_images)
  File "/usr/lib/python2.7/gzip.py", line 261, in read
    self._read(readsize)
  File "/usr/lib/python2.7/gzip.py", line 312, in _read
    uncompress = self.decompress.decompress(buf)
zlib.error: Error -3 while decompressing: invalid block type


我正在使用安装在14.04 Ubuntu操作系统中的Python2.7。

最佳答案

问题的根源似乎是无效的数据文件:“ data / train-images-idx3-ubyte.gz”。
有什么方法可以获取文件的新副本?
请使用以下shell命令验证文件的新副本:

gunzip -t  data/train-images-idx3-ubyte.gz


一旦上述测试返回gz文件有效的答案,请执行脚本:

python convolutional.py

关于python - zlib.error:解压缩时出错-3:无效的距离代码,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/36055090/

10-12 05:22