EOFError:压缩文件在到达流结束标记之前结束 - MNIST 数据集 [英] EOFError: Compressed file ended before the end-of-stream marker was reached - MNIST data set

查看:102
本文介绍了EOFError:压缩文件在到达流结束标记之前结束 - MNIST 数据集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我运行 mnist = input_data.read_data_sets("MNIST_data", one_hot = True) 时出现以下错误.

I am getting the following error when I run mnist = input_data.read_data_sets("MNIST_data", one_hot = True).

EOFError:压缩文件在到达流结束标记之前结束

EOFError: Compressed file ended before the end-of-stream marker was reached

即使我手动解压缩文件并将其放在 MNIST_data 目录中,程序仍在尝试下载文件而不是使用提取的文件.

Even when I extract the file manually and place it in the MNIST_data directory, the program is still trying to download the file instead of using the extracted file.

当我使用手动方式 WinZip 解压缩文件时,WinZip 告诉我文件已损坏.

When I extract the file using WinZip which is the manual way, WinZip tells me that the file is corrupt.

我该如何解决这个问题?

我现在连数据集都加载不了,我还要自己调试程序.请帮忙.

I can't even load the data set now, I still have to debug the program itself. Please help.

我 pip 安装了 Tensorflow,所以我没有 Tensorflow 示例.所以我去GitHub获取了input_data文件并将其保存在与我的main.py相同的目录中.该错误仅与 .gz 文件有关.程序无法解压.

I pip installed Tensorflow and so I don't have a Tensorflow example. So I went to GitHub to get the input_data file and saved it in the same directory as my main.py. The error is just regarding the .gz file. The program could not extract it.

runfile('C:/Users/Nikhil/Desktop/Tensor Flow/tensf.py', wdir='C:/Users/Nikhil/Desktop/Tensor Flow')重新加载的模块:input_data提取 MNIST_data/train-images-idx3-ubyte.gzC:\Users\Nikhil\Anaconda3\lib\gzip.py:274: VisibleDeprecationWarning: 将 ndim > 0 的数组转换为索引会导致以后出错返回 self._buffer.read(size)回溯(最近一次调用):

runfile('C:/Users/Nikhil/Desktop/Tensor Flow/tensf.py', wdir='C:/Users/Nikhil/Desktop/Tensor Flow') Reloaded modules: input_data Extracting MNIST_data/train-images-idx3-ubyte.gz C:\Users\Nikhil\Anaconda3\lib\gzip.py:274: VisibleDeprecationWarning: converting an array with ndim > 0 to an index will result in an error in the future return self._buffer.read(size) Traceback (most recent call last):

文件",第 1 行,在runfile('C:/Users/Nikhil/Desktop/Tensor Flow/tensf.py', wdir='C:/Users/Nikhil/Desktop/Tensor Flow')

File "", line 1, in runfile('C:/Users/Nikhil/Desktop/Tensor Flow/tensf.py', wdir='C:/Users/Nikhil/Desktop/Tensor Flow')

文件C:\Users\Nikhil\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py",第 866 行,在运行文件中execfile(文件名,命名空间)

File "C:\Users\Nikhil\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 866, in runfile execfile(filename, namespace)

文件C:\Users\Nikhil\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py",第 102 行,在 execfile 中exec(compile(f.read(), filename, 'exec'), namespace)

File "C:\Users\Nikhil\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 102, in execfile exec(compile(f.read(), filename, 'exec'), namespace)

文件C:/Users/Nikhil/Desktop/Tensor Flow/tensf.py",第 26 行,在mnist = input_data.read_data_sets("MNIST_data/", one_hot = True)

File "C:/Users/Nikhil/Desktop/Tensor Flow/tensf.py", line 26, in mnist = input_data.read_data_sets("MNIST_data/", one_hot = True)

文件C:\Users\Nikhil\Desktop\Tensor Flow\input_data.py",第 181 行,在 read_data_sets 中train_images = extract_images(local_file)

File "C:\Users\Nikhil\Desktop\Tensor Flow\input_data.py", line 181, in read_data_sets train_images = extract_images(local_file)

文件C:\Users\Nikhil\Desktop\Tensor Flow\input_data.py",第 60 行,在 extract_images 中buf = bytestream.read(rows * cols * num_images)

File "C:\Users\Nikhil\Desktop\Tensor Flow\input_data.py", line 60, in extract_images buf = bytestream.read(rows * cols * num_images)

文件C:\Users\Nikhil\Anaconda3\lib\gzip.py",第 274 行,已读返回 self._buffer.read(size)

File "C:\Users\Nikhil\Anaconda3\lib\gzip.py", line 274, in read return self._buffer.read(size)

文件C:\Users\Nikhil\Anaconda3\lib_compression.py",第 68 行,读入数据 = self.read(len(byte_view))

File "C:\Users\Nikhil\Anaconda3\lib_compression.py", line 68, in readinto data = self.read(len(byte_view))

文件C:\Users\Nikhil\Anaconda3\lib\gzip.py",第 480 行,已读raise EOFError("压缩文件在

File "C:\Users\Nikhil\Anaconda3\lib\gzip.py", line 480, in read raise EOFError("Compressed file ended before the "

EOFError:压缩文件在到达流结束标记之前结束

EOFError: Compressed file ended before the end-of-stream marker was reached

推荐答案

这是因为出于某种原因,您没有完整的 MNIST 数据集下载.

This is because for some reason you have an incomplete download for the MNIST dataset.

您必须手动删除下载的文件夹,该文件夹通常位于 ~/.keras/datasets 或您指定的相对于该路径的任何路径中,在您的情况下为 MNIST_data.

You will have to manually delete the downloaded folder which usually resides in ~/.keras/datasets or any path specified by you relative to this path, in your case MNIST_data.

在终端中执行以下步骤(ctrl + alt + t):

Perform the following steps in the terminal (ctrl + alt + t):

  1. cd ~/.keras/datasets/
  2. rm -rf "数据集名称"

你应该没事了!

这篇关于EOFError:压缩文件在到达流结束标记之前结束 - MNIST 数据集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆