gpt4 book ai didi

python - EOFError : Compressed file ended before the end-of-stream marker was reached - MNIST data set 错误

转载 作者:太空狗 更新时间:2023-10-30 01:53:26 46 4
gpt4 key购买 nike

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

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

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

当我使用手动方式使用 WinZip 提取文件时,WinZip 告诉我文件已损坏。

我该如何解决这个问题?

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

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

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):

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

File "C:\Users\Nikhil\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 866, in runfile execfile(filename, 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)

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

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

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

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

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

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

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

最佳答案

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

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

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

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

你应该可以开始了!

关于python - EOFError : Compressed file ended before the end-of-stream marker was reached - MNIST data set 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40877781/

46 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com