首页 > 解决方案 > 加载时尚 mnist 数据集时出错

问题描述

import tensorflow as tf
from tensorflow import keras
fashion_mnist = tf.keras.datasets.fashion_mnist

(train_images, train_labels), (test_images, test_labels) = fashion_mnist.load_data()

我收到了这个错误

EOFError                                  Traceback (most recent call last)
<ipython-input-1-d38ad79b1741> in <module>
      3 fashion_mnist = tf.keras.datasets.fashion_mnist
      4 
----> 5 (train_images, train_labels), (test_images, test_labels) = fashion_mnist.load_data()

~\miniconda3\lib\site-packages\tensorflow\python\keras\datasets\fashion_mnist.py in load_data()
     82   with gzip.open(paths[1], 'rb') as imgpath:
     83     x_train = np.frombuffer(
---> 84         imgpath.read(), np.uint8, offset=16).reshape(len(y_train), 28, 28)
     85 
     86   with gzip.open(paths[2], 'rb') as lbpath:

~\miniconda3\lib\gzip.py in read(self, size)
    290             import errno
    291             raise OSError(errno.EBADF, "read() on write-only GzipFile object")
--> 292         return self._buffer.read(size)
    293 
    294     def read1(self, size=-1):

~\miniconda3\lib\gzip.py in read(self, size)
    496                 break
    497             if buf == b"":
--> 498                 raise EOFError("Compressed file ended before the "
    499                                "end-of-stream marker was reached")
    500 

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

在stackoverflow上我找到了一个答案,说删除现有文件并再次下载,但这不起作用

标签: tensorflowkerasdeep-learningimage-classification

解决方案


推荐阅读