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

后端 未结 20 2205
花落未央
花落未央 2020-12-04 11:28

I\'m trying to implement the binary classification example using the IMDb dataset in Google Colab. I have implemented this model before. But when I tried to

20条回答
  •  独厮守ぢ
    2020-12-04 11:42

    Following this issue on GitHub, the official solution is to edit the imdb.py file. This fix worked well for me without the need to downgrade numpy. Find the imdb.py file at tensorflow/python/keras/datasets/imdb.py (full path for me was: C:\Anaconda\Lib\site-packages\tensorflow\python\keras\datasets\imdb.py - other installs will be different) and change line 85 as per the diff:

    -  with np.load(path) as f:
    +  with np.load(path, allow_pickle=True) as f:
    

    The reason for the change is security to prevent the Python equivalent of an SQL injection in a pickled file. The change above will ONLY effect the imdb data and you therefore retain the security elsewhere (by not downgrading numpy).

提交回复
热议问题