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.

3
  • 1
    Why are you trying to load the IMDB dataset manually?
    – Dr. Snoopy
    Commented Aug 12, 2019 at 13:17
  • cause I am behind a proxy...and not allowed to load it directly...
    – PV8
    Commented Aug 12, 2019 at 13:18
  • There are alternatives in that case, we have an XY problem here.
    – Dr. Snoopy
    Commented Aug 12, 2019 at 13:20

2 Answers 2

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?

2
  • when i Run: imdb = keras.datasets.imdb.load_data(), I receive the error: ValueError: Object arrays cannot be loaded when allow_pickle=False
    – PV8
    Commented Aug 12, 2019 at 13:29
  • 1
    @PV8 stackoverflow.com/questions/55890813/…
    – Dr. Snoopy
    Commented Aug 12, 2019 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)

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.
    – Community Bot
    Commented Jan 11, 2023 at 15:37

Not the answer you're looking for? Browse other questions tagged or ask your own question.