首页 > 解决方案 > 难以导入“fashion_mnist”数据

问题描述

错误

当我运行以下代码导入fashion_mnist数据时:

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

我得到:

ValueError Traceback (last last call last) in () 1 fashion_mnist = keras.datasets.fashion_mnist 2 ----> 3 (train_images, train_labels), (test_images, test_labels) = fashion_mnist.load_data()

~/Asha/machineLearningAsha/anaconda3/lib/python3.6/site-packages/tensorflow/python/keras/datasets/fashion_mnist.py

在 load_data() 64 中,gzip.open(paths[3], 'rb') as imgpath: 65 x_test = np.frombuffer( ---> 66 imgpath.read(), np.uint8, offset=16).reshape (len(y_test), 28, 28) 67 68 返回 (x_train, y_train), (x_test, y_test)

ValueError: offset must be non-negative and no greater than buffer length (0)

有人可以帮我导入“fashion_mnist”数据吗?

标签: python-3.xkeras

解决方案


在执行对我有用的这个命令之后从 keras 文件夹中删除该数据集之后

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

推荐阅读