Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

385
Views
¿Cómo arreglar 'Las matrices de objetos no se pueden cargar cuando allow_pickle=False' para la función imdb.load_data()?

Estoy tratando de implementar el ejemplo de clasificación binaria utilizando el conjunto de datos de IMDb en Google Colab . He implementado este modelo antes. Pero cuando traté de hacerlo nuevamente después de unos días, devolvió un value error: 'Object arrays cannot be loaded when allow_pickle=False' para la función load_data().

Ya intenté resolver esto, refiriéndose a una respuesta existente para un problema similar: Cómo corregir 'Las matrices de objetos no se pueden cargar cuando allow_pickle=False' en el algoritmo sketch_rnn . Pero resulta que simplemente agregar un argumento allow_pickle no es suficiente.

Mi código:

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

El error:

 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
over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

Aquí hay un truco para obligar a imdb.load_data a permitir pickle by, en su cuaderno, reemplazando esta línea:

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

por esto:

 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
over 4 years ago · Santiago Trujillo Report

0

Este problema sigue pendiente en keras git. Espero que se solucione lo antes posible. Hasta entonces, intente degradar su versión numpy a 1.16.2. Parece resolver el problema.

 !pip install numpy==1.16.1 import numpy as np

Esta versión de numpy tiene el valor predeterminado de allow_pickle como True .

over 4 years ago · Santiago Trujillo Report

0

Acabo de usar allow_pickle = True como argumento para np.load() y funcionó para mí.

np.load(path, allow_pickle=True)

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!