close

How to fix ‘Object arrays cannot be loaded when allow_pickle=False’ for imdb.load_data() function?

Hello Guys, How are you all? Hope You all Are Fine. Today We Are Going To learn about How to fix ‘Object arrays cannot be loaded when allow_pickle=False’ for imdb.load_data() function in Python. So Here I am Explain to you all the possible Methods here.

Without wasting your time, Let’s start This Article.

How to fix ‘Object arrays cannot be loaded when allow_pickle=False’ for imdb.load_data() function?

  1. How to fix 'Object arrays cannot be loaded when allow_pickle=False' for imdb.load_data() function?

    This issue is still up on keras git. I hope it gets solved as soon as possible. Until then, try downgrading your numpy version to 1.16.2. It seems to solve the problem.

  2. fix 'Object arrays cannot be loaded when allow_pickle=False' for imdb.load_data() function

    This issue is still up on keras git. I hope it gets solved as soon as possible. Until then, try downgrading your numpy version to 1.16.2. It seems to solve the problem.

Method 1

Here’s a trick to force imdb.load_data to allow pickle by, in your notebook, replacing this line:

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

by this:

import numpy as np
# save np.load
np_load_old = np.load

# modify the default parameters of np.load
np.load = lambda *a,**k: np_load_old(*a, allow_pickle=True, **k)

# call load_data with allow_pickle implicitly set to true
(train_data, train_labels), (test_data, test_labels) = imdb.load_data(num_words=10000)

# restore np.load for future normal usage
np.load = np_load_old

Method 2

This issue is still up on keras git. I hope it gets solved as soon as possible. Until then, try downgrading your numpy version to 1.16.2. It seems to solve the problem.

!pip install numpy==1.16.1
import numpy as np

This version of numpy has the default value of allow_pickle as True.

Summery

It’s all About this issue. Hope all Methods helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which Method worked for you? Thank You.

Also, Read