haogeng1
haogeng1
采纳率0%
2020-02-09 01:28

tensorflow在第一次运行Fashion MNIST会下载数据集,应该网络不好中断了报错不知咋办?

```**tensorflow在第一次运行Fashion MNIST会下载数据集,应该网络不好中断了报错不知咋办?**

代码如下:
!/usr/bin/python

* coding: utf-8 -*-

from future import print_function

import tensorflow as tf

import matplotlib as mpl

import matplotlib.pyplot as plt

%matplotlib inline

import numpy as np

import sklearn

import pandas as pd

import os

import sys

import time

from tensorflow import keras

print (tf.__version__)

print (sys.version_info)

for module in mpl ,np, pd, sklearn, tf, keras:

print (module.__name__,module.__version__)

fashion_mnist = keras.datasets.fashion_mnist

(x_train_all,y_train_all),(x_test,y_test) = fashion_mnist.load_data()

x_valid,x_train = x_train_all[:5000],x_train_all[5000:]

y_valid,y_train = y_train_all[:5000],y_train_all[5000:]

print (x_valid.shape, y_valid.shape)

print (x_train.shape, y_train.shape)

print (x_test.shape, y_test.shape)


报错如下:

2.1.0
sys.version_info(major=2, minor=7, micro=12, releaselevel='final', serial=0)

matplotlib 2.2.5

numpy 1.16.6

pandas 0.24.2

sklearn 0.20.4

tensorflow 2.1.0

tensorflow_core.python.keras.api._v2.keras 2.2.4-tf

Traceback (most recent call last):

File "/home/join/test_demo/test2.py", line 26, in

(x_train_all,y_train_all),(x_test,y_test) = fashion_mnist.load_data()

File "/usr/local/lib/python2.7/dist-packages/tensorflow_core/python/keras/data

sets/fashion_mnist.py", line 59, in load_data

imgpath.read(), np.uint8, offset=16).reshape(len(y_train), 28, 28)

File "/usr/lib/python2.7/gzip.py", line 261, in read

self._read(readsize)

File "/usr/lib/python2.7/gzip.py", line 315, in _read

self._read_eof()

File "/usr/lib/python2.7/gzip.py", line 354, in _read_eof

hex(self.crc)))

IOError: CRC check failed 0xa445bb78 != 0xe7f80d

3fL


  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

2条回答

  • tushuguan_sun 林风风 1年前

    网络不好的话,用下面命令下载数据集非常慢,而且容易报错的。

    fashion_mnist = keras.datasets.fashion_mnist
    (x_train_all,y_train_all),(x_test,y_test) = fashion_mnist.load_data()
    

    可以使用迅雷先把数据集下载下来,然后放到对应的文件夹,具体步骤可以参考如下链接,写的还是非常简单明了的:
    解决在Tensorflow中下载数据集太慢的问题

    有用的话,赞一个鼓励下哦

    点赞 1 评论 复制链接分享
  • caozhy 回答这么多问题就耍赖把我的积分一笔勾销了 1年前

    网络不好的话,你可以使用“虚拟的私有的网络技术”拨号上网

    点赞 评论 复制链接分享

为你推荐