【问题标题】:keras load_model not work in google colabkeras load_model 在谷歌 colab 中不起作用
【发布时间】:2020-04-09 17:12:20
【问题描述】:

我尝试加载我在本地机器中创建的模型,所以首先我将我的模型(.h5)上传到谷歌驱动器,然后我使用以下代码在 colab 中访问我的模型

from google.colab import drive
drive.mount('/content/drive')

然后我尝试使用以下代码

from keras.models import load_model
classifier = load_model('/content/drive/My Drive/Colab Notebooks/face_shape_recog_model.h5')

运行上面的代码后出现以下错误

AttributeError: module 'tensorflow' has no attribute 'placeholder'

我尝试卸载并安装 tensorflow 和 keras,但仍然面临同样的问题 我还尝试了github issue

中提到的解决方案

谢谢你

【问题讨论】:

    标签: tensorflow machine-learning keras deep-learning google-colaboratory


    【解决方案1】:

    我怀疑这是由于 keras 2.2 和 tensorflow 2.x 之间的不兼容造成的。您应该能够通过更新到 keras 2.3 或更高版本来解决此问题:

    !pip install -U keras
    

    编辑 2020-04-10:看起来 Keras 2.3 现在是 Colab 中的默认版本,因此不再需要上述修复。

    【讨论】:

      猜你喜欢
      • 2021-01-01
      • 1970-01-01
      • 2021-12-12
      • 1970-01-01
      • 2019-05-07
      • 2020-08-21
      • 1970-01-01
      • 2021-04-19
      • 2021-01-26
      相关资源
      最近更新 更多