I\'m trying to implement the binary classification example using the IMDb dataset in Google Colab. I have implemented this model before. But when I tried to
I don't usually post to these things but this was super annoying. The confusion comes from the fact that some of the Keras imdb.py
files have already updated:
with np.load(path) as f:
to the version with allow_pickle=True
. Make sure check the imdb.py file to see if this change was already implemented. If it has been adjusted, the following works fine:
from keras.datasets import imdb
(train_text, train_labels), (test_text, test_labels) = imdb.load_data(num_words=10000)
I just used allow_pickle = True as an argument to np.load() and it worked for me.
find the path to imdb.py then just add the flag to np.load(path,...flag...)
def load_data(.......):
.......................................
.......................................
- with np.load(path) as f:
+ with np.load(path,allow_pickle=True) as f:
The error also can occur if you try to save a python list of numpy arrays with np.save and load with np.load. I am only saying it for the sake of googler's to check out that this is not the issue. Also using allow_pickle=True
fixed the issue if a list is indeed what you meant to save and load.
Use this
from tensorflow.keras.datasets import imdb
instead of this
from keras.datasets import imdb
Tensorflow has a fix in tf-nightly version.
!pip install tf-nightly
The current version is '2.0.0-dev20190511'.