0

following this instruction: the alternative to from keras.datasets import mnist

I am able to load the mnist dataset, with the following lines:

f = gzip.open('C:/.../Datasets/mnist.pkl.gz', 'rb')
if sys.version_info < (3,):
    data = pickle.load(f)
else:
    data = pickle.load(f, encoding='bytes')
f.close()

(x_train, y_train),(x_test, y_test) = data

But when I try the same for the IMDB dataset, which i saved as tar.gz file, which the following command:

imdb = gzip.open('C:/.../Datasets/aclImdb_v1.tar.gz', 'rb')
if sys.version_info < (3,):
    data = pickle.load(imdb)
else:
    data = pickle.load(imdb, encoding='bytes')
imdb.close()

I get the error:

UnpicklingError: unpickling stack underflow

I am not allowed to load it with:

imdb = keras.datasets.imdb

(train_data, train_labels), (test_data, test_labels) = imdb.load_data(num_words=10000)

because I am behind a proxy.

PV8
  • 5,799
  • 7
  • 43
  • 87

2 Answers2

2

Since you are behind a proxy, there are alternatives to download the dataset:

If you get errors about pickle, then look at: How to fix 'Object arrays cannot be loaded when allow_pickle=False' for imdb.load_data() function?

Dr. Snoopy
  • 55,122
  • 7
  • 121
  • 140
  • when i Run: `imdb = keras.datasets.imdb.load_data()`, I receive the error: `ValueError: Object arrays cannot be loaded when allow_pickle=False` – PV8 Aug 12 '19 at 13:29
  • 1
    @PV8 https://stackoverflow.com/questions/55890813/how-to-fix-object-arrays-cannot-be-loaded-when-allow-pickle-false-for-imdb-loa – Dr. Snoopy Aug 12 '19 at 13:31
0

It works well behind the proxy:

(train_data, train_labels), (test_data, test_labels) =
imdb.load_data(path = "/Users/username/anaconda3/Lib/site-packages/keras/datasets/imdb.npz", num_words=10000)

Mostafa
  • 1
  • 1
  • 1
    As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jan 11 '23 at 15:37