[英]Google Colab error: Import "tensorflow.keras.models" could not be resolved(reportMissingImports)
import tensorflow as tf
tf.__version__
!sudo pip3 install keras
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense, Conv2D, Flatten, Dropout, MaxPooling2D
from tensorflow.keras.preprocessing.image import ImageDataGenerator
错误信息:
Import "tensorflow.keras.models" could not be resolved(reportMissingImports)
>Import "tensorflow.keras.layers" could not be resolved(reportMissingImports)
>>Import "tensorflow.keras.preprocessing.image" could not be resolved(reportMissingImports)
import tensorflow as tf
tf.__version__
!sudo pip3 install keras
from tensorflow.python.keras.engine.sequential import Sequential
from tensorflow.python.keras.layers import Dense, Conv2D, Flatten, Dropout, MaxPooling2D
image_data_generator = tf.keras.preprocessing.image.ImageDataGenerator()
我有同样的错误,我做了这些步骤步骤 01 :用这个指令卸载现有的 tensorflow
!pip uninstall tensorflow
步骤 02:安装此版本我希望您通过此说明在此版本中找到您需要的内容
!pip install tensorflow==2.7.0
如果 2.7.0 不适合您的代码,您可以更改 tensorflow 的版本
问题解决了。
虽然报错: Import "tensorflow.keras.models" could not be resolved(reportMissingImports)
,但不影响整个代码。 我的 Tensorflow 版本是 2.8.0。 我刚刚发现问题出在我的 cnn model 的配置上。
我解决了。
问题是我的版本太新了。 您只需降低 TensorFlow 版本,使其适合您的要求。 我使用pip install tensorflow==2.7.0.
检查这些图像,警告线对我来说消失了。
这对我有用。
'从 tensorflow 导入 keras
从 keras.layers 导入密集
从 keras.models 导入顺序,load_model'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.