Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask question.(5)

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

ITtutoria

ITtutoria Logo ITtutoria Logo

ITtutoria Navigation

  • Python
  • Java
  • Reactjs
  • JavaScript
  • R
  • PySpark
  • MYSQL
  • Pandas
  • QA
  • C++
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Python
  • Science
  • Java
  • JavaScript
  • Reactjs
  • Nodejs
  • Tools
  • QA
Home/Questions/Amazing Solutions For valueerror: object arrays cannot be loaded when allow_pickle=false Error
Next
Answered
Gabin Raynaud
  • 25
Gabin Raynaud
Asked: May 11, 20222022-05-11T19:10:35+00:00 2022-05-11T19:10:35+00:00In: Programs

Amazing Solutions For valueerror: object arrays cannot be loaded when allow_pickle=false Error

  • 25

I get the error: valueerror: object arrays cannot be loaded when allow_pickle=false when I try to run the program below:

from keras.datasets import imdb
 (train_data, train_labels), (test_data, test_labels) = imdb.load_data(num_words=10000)

The error appears the system notifies as follows:

ValueError Traceback (most recent call last)
 <ipython-input-1-2ab3902db485> in <module>()
  1 from keras.datasets import imdb
 ----> 2 (train_data, train_labels), (test_data, test_labels) = imdb.load_data(num_words=10000)
 
 2 frames
 /usr/local/lib/python3.6/dist-packages/keras/datasets/imdb.py in load_data(path, num_words, skip_top, maxlen, seed, start_char, oov_char, index_from, **kwargs)
  57 file_hash='599dadb1135973df5b59232a0e9a887c')
  58 with np.load(path) as f:
 ---> 59 x_train, labels_train = f['x_train'], f['y_train']
  60 x_test, labels_test = f['x_test'], f['y_test']
  61 
 
 /usr/local/lib/python3.6/dist-packages/numpy/lib/npyio.py in __getitem__(self, key)
  260 return format.read_array(bytes,
  261 allow_pickle=self.allow_pickle,
 --> 262 pickle_kwargs=self.pickle_kwargs)
  263 else:
  264 return self.zip.read(key)
 
 /usr/local/lib/python3.6/dist-packages/numpy/lib/format.py in read_array(fp, allow_pickle, pickle_kwargs)
  690 # The array contained Python objects. We need to unpickle the data.
  691 if not allow_pickle:
 --> 692 raise ValueError("Object arrays cannot be loaded when "
  693 "allow_pickle=False")
  694 if pickle_kwargs is None:
 
 ValueError: Object arrays cannot be loaded when allow_pickle=False

I tried to solve it with another sample. I got the reference in the community forum, but it still returned an invalid result. If someone knows the solution, please give me the support. Thanks!

object arrays cannot be loaded
  • 2 2 Answers
  • 79 Views
  • 0 Followers
  • 0
Answer
Share
  • Facebook
  • Report

2 Answers

  • Voted
  • Oldest
  • Recent
  • Random
  1. Best Answer
    dhtutoria Expert
    2022-06-03T02:40:19+00:00Added an answer on June 3, 2022 at 2:40 am

    The cause: The error can occur due to the following reasons: Saving a python list of numpy arrays that used np.save and then it is loaded with np.load. Therefore, imdb.load_data didn’t allow pickle.

    Solution: You should do this way to compel imdb.load_data to permit pickle.

    Change:

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

    into:

    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
    
    👇️ Read more: Fixing “ValueError: Object arrays cannot be loaded when allow_pickle=False”
    • 17
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report
  2. Maël Papin
    2022-05-25T19:30:08+00:00Added an answer on May 25, 2022 at 7:30 pm

    This issue “valueerror: object arrays cannot be loaded” is still on keras Git. It will be resolved as soon as possible, I hope you can try to downgrade your numpy version until then to 1.16.2. This seems to fix the problem.

    !pip install numpy==1.16.1
    import numpy as np

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

    • 13
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

Sidebar

Ask A Question

  • How to Split String by space in C++
  • How To Convert A Pandas DataFrame Column To A List
  • How to Replace Multiple Characters in A String in Python?
  • How To Remove Special Characters From String Python

Explore

  • Home
  • Tutorial

Footer

ITtutoria

ITtutoria

This website is user friendly and will facilitate transferring knowledge. It would be useful for a self-initiated learning process.

@ ITTutoria Co Ltd.

Tutorial

  • Home
  • Python
  • Science
  • Java
  • JavaScript
  • Reactjs
  • Nodejs
  • Tools
  • QA

Legal Stuff

  • About Us
  • Terms of Use
  • Privacy Policy
  • Contact Us

DMCA.com Protection Status

Help

  • Knowledge Base
  • Support

Follow

© 2022 Ittutoria. All Rights Reserved.

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.