BadZipFile: File is not a zip by importing keras

烈酒焚心 提交于 2019-12-06 06:08:27

问题


When I run this code, I got the following error. I have tried different techniques to get rid of this problem but couldn't.

May I request to someone who can help me to solve this issue. There are some solutions to the same problem but I couldn't get theirs points to fix it.

import numpy

from keras.datasets import imdb
(X_train, y_train), (X_test, y_test) = imdb.load_data()

X = numpy.concatenate((X_train, X_test), axis=0)

y = numpy.concatenate((y_train, y_test), axis=0)

Using Theano backend.

BadZipFile    
/home/maaz/anaconda3/lib/python3.6/zipfile.py in _RealGetContents(self)
   1165             raise BadZipFile("File is not a zip file")
   1166         if not endrec:
-> 1167             raise BadZipFile("File is not a zip file")
   1168         if self.debug > 1:
   1169             print(endrec)

BadZipFile: File is not a zip file                            Traceback (most recent call 

BadZipFile: File is not a zip file

回答1:


This could have happened when a previous download has stopped for some reason resulting in a bad zip file in keras cache. Try cleaning the keras dataset cache: rm ~/.keras/datasets/*




回答2:


I have the same problem. I was downloading half way and then I had to go to work, so i stopped the download. after work, I rerun the program, and it gives me the same message. I have a Mac OS how I do clean the case from the dataset? thanks.

i figured it out. I actually had to do rm -R .keras/datasets on bash.



来源:https://stackoverflow.com/questions/44077111/badzipfile-file-is-not-a-zip-by-importing-keras

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!