Tensorflow 问题 google colab ; tensorflow._api.v1.compat.v2' 没有属性 '__internal__

Tensorflow issue google colab ; tensorflow._api.v1.compat.v2' has no attribute '__internal__

Tensorflow 问题 google colab:模块 'tensorflow._api.v1.compat.v2' 没有属性 'internal' 我是 运行 google colab 上的 MASK RCNN 模型 使用 tensorflow 1.15 和 keras 2.1.6 一切正常,但今天,我收到此错误: enter image description here

尽管在 Github 中提供了解决方案,但为了社区的利益,请在此处提供解决方案。

最近 colab 升级到 TF 2.5.0,强制升级到 keras-nightly 2.5.0.dev2021032900

影响您的最近更改是 keras-nightly 的安装,它与非夜间 keras!pip install 不兼容。在 import keras 之前添加 !pip uninstall keras-nightly 会使错误消失。

来自评论

 !pip uninstall keras-nightly

 !pip uninstall -y tensorflow

 !pip install h5py==2.10.0  

Followed by fresh installation of tensorflow and keras as per requirement has solved the problem (paraphrased from nada belhadjslimen)