Tensorflow相关问题汇总

  1. AttributeError: module ‘tensorflow’ has no attribute ‘compat’ when importing tensorflow

问题详述:在利用 Anaconda 安装 tensorflow 2.1 后,运行时出现报错:AttributeError: module ‘tensorflow’ has no attribute ‘compat’ when importing tensorflow,
分析后需要安装对应版本的tensorflow-estimator
通过pip show tensorflow查看安装的Tensorflow版本,比如我是Tensorflow 2.1版本,就安装2.1版本的tensorflow-estimator

pip show tensorflow
conda install tensorflow-estimator==2.1

在这里插入图片描述PS. 本来from tensorflow.keras import layers, Sequentialfrom tensorflow.keras.datasets import imdb这种操作是报错的,但是安装后,发现不报错了


版权声明:本文为weixin_43482048原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。