【发布时间】:2021-08-14 04:50:55
【问题描述】:
我昨天尝试使用 TensorFlow 作为后端,我可以使用它,但今天当我尝试导入 Keras 时使用它显示一些错误消息,所以这是我的代码:
# Install required libs
# NOTE: Run this one code, then restart this runtime and run again for next all... (PENTING!!!)
### please update Albumentations to version>=0.3.0 for `Lambda` transform support
!pip install -U segmentation-models
!pip install q tensorflow==2.1
!pip install q keras==2.3.1
!pip install tensorflow-estimator==2.1.
## Imports libs
import os
os.environ['CUDA_VISIBLE_DEVICES'] = '0'
import cv2
import Keras
import NumPy as np
import matplotlib.pyplot as plt
它显示了这个错误:
AttributeError Traceback (most recent call last)
<ipython-input-3-9c78a7be919d> in <module>()
5
6 import cv2
----> 7 import keras
8 import numpy as np
9 import matplotlib.pyplot as plt
8 frames
/usr/local/lib/python3.7/dist-packages/keras/initializers/__init__.py in populate_deserializable_objects()
47
48 LOCAL.ALL_OBJECTS = {}
---> 49 LOCAL.GENERATED_WITH_V2 = tf.__internal__.tf2.enabled()
50
51 # Compatibility aliases (need to exist in both V1 and V2).
AttributeError: module 'tensorflow.compat.v2.__internal__' has no attribute 'tf2'
虽然我使用的是 TensorFlow 2.2 版和 Keras 2.3.1 版,但昨天我可以运行,但今天似乎不能。我今天是否为我的 Keras 和 TensorFlow 导入了错误的版本?
编辑:
当我使用 from tensorFlow import keras 时,我想要的输出 using tensorflow backend 不显示,然后当我加载 import segmentation_models as sm 时,当我使用上面的 import Keras 时,它显示相同的错误。
【问题讨论】:
标签: python tensorflow machine-learning keras deep-learning