错误解决Object arrays cannot be loaded when allow_pickle=False

在运行《Deep Learning with Python》书中的代码时出现了这一个错误。书内代码如下:

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

以上三段代码直接运行都会出现如下错误:

Object arrays cannot be loaded when allow_pickle=False

解决方法:

  1. 在文件夹中找到imdb.pyreuters.pyboston_housing.py文件
    地址的模样一般张得像底下这样:

    C:\ProgramData\Anaconda3\envs\Python_try\Lib\site-packages\keras\datasets
    
  2. 在代码中找到np.load(path),将它改为np.load(path, allow_pickle=True)

  3. 保存,然后重启Kernel

完成!

参考链接:

https://www.cnblogs.com/heenhui2016/p/10905281.html
https://github.com/tensorflow/tensorflow/issues/28102

你可能感兴趣的:(python3,Deep,Learning)