Cannot manually load kears imbd dataset

Question:

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.

Asked By: PV8

||

Answers:

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?

Answered By: Dr. Snoopy

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)

Answered By: Mostafa
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.