Ice Tweak
Ice Tweak

Reputation: 33

How to fix error when load dataset in Keras?

When I'm load 'reuters' dataset , I get a Error

I try using some :

np_load_old = np.load
np.load = lambda *a,**k: np_load_old(*a, allow_pickle=True, **k)
(train_data, train_labels), (test_data, test_labels) = reuters.load_data(num_words=10000)
np.load = np_load_old

Originally is :

from keras.datasets import reuters
import numpy as np
(train_data, train_labels), (test_data, test_labels) = reuters.load_data(num_words=10000)

TypeError: () got multiple values for keyword argument 'allow_pickle'

Full traceback:

    TypeError                                 Traceback (most recent call last)
    <ipython-input-11-8669b9ae66ea> in <module>()
          1 from keras.datasets import reuters
    ----> 2 (train_data, train_labels), (test_data, test_labels) = reuters.load_data(num_words=10000)
          3 
          4 

    2 frames
    <ipython-input-2-8333ca7e6c7f> in <lambda>(*a, **k)
          4 
          5 np_load_old = np.load
    ----> 6 np.load = lambda *a,**k: np_load_old(*a, allow_pickle=True, **k)
          7 (train_data, train_labels), (test_data, test_labels) = imdb.load_data(num_words=10000)
     >     8 np.load = np_load_old

TypeError: <lambda>() got multiple values for keyword argument 'allow_pickle'

Upvotes: 3

Views: 6791

Answers (2)

Murugan R
Murugan R

Reputation: 21

Refer this solution. This is working for me.

I solved the issue by deleting the **k in old(). This is because **k contains allow_pickle. So my command line changed from this:

np.load = lambda *a,**k: old(*a,allow_pickle=True,**k)

to this:

np.load = lambda *a,**k: old(*a,allow_pickle=True)

Remember to restart your runtime if you have run the command with **k in old() before you execute the corrected command line.

Upvotes: 1

Yasser Elbarbay
Yasser Elbarbay

Reputation: 133

so it took me a while to figure this out, but I finally fixed it. since our problem is the default values of np.load then we simply need to change them(temporarily at least).

so before using numpy you can simply add this line to your code:

np.load.__defaults__=(None, True, True, 'ASCII')

this will change allow_pickle to True.

then when you're done with what you were doing fix it back

np.load.__defaults__=(None, False, True, 'ASCII')

Cheers!

Upvotes: 6

Related Questions