Сначала я использую Tensorflow 1.15 и Keras 2.2.4.
Я запустил следующий код в блокноте Jupyter:
from keras.datasets import imdb
from keras import preprocessing
max_features = 10000
maxlen = 20
(x_train, y_train), (x_test, y_test) = imdb.load_data(
num_words=max_features)
x_train = preprocessing.sequence.pad_sequences(x_train, maxlen=maxlen)
x_test = preprocessing.sequence.pad_sequences(x_test, maxlen=maxlen)
, и он выдал мне эту ошибку:
Downloading data from https://s3.amazonaws.com/text-datasets/imdb.npz
17465344/17464789 [==============================] - 8s 0us/step
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-6-609d113f6ed2> in <module>
6
7 (x_train, y_train), (x_test, y_test) = imdb.load_data(
----> 8 num_words=max_features)
9
10 x_train = preprocessing.sequence.pad_sequences(x_train, maxlen=maxlen)
~\.conda\envs\tensorflow_env\lib\site-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
~\.conda\envs\tensorflow_env\lib\site-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)
~\.conda\envs\tensorflow_env\lib\site-packages\numpy\lib\format.py in read_array(fp, allow_pickle, pickle_kwargs)
720 # The array contained Python objects. We need to unpickle the data.
721 if not allow_pickle:
--> 722 raise ValueError("Object arrays cannot be loaded when "
723 "allow_pickle=False")
724 if pickle_kwargs is None:
ValueError: Object arrays cannot be loaded when allow_pickle=False
Что с ним не так? Я взял этот код из книги "Deep Learning with Python".
Спасибо