gpt4 book ai didi

python - 模块 'tensorflow._api.v1.compat.v2' 没有属性 '__internal__' google colab 错误

转载 作者:行者123 更新时间:2023-12-04 14:32:40 26 4
gpt4 key购买 nike

我正在 google colab 上运行 tensorflow 模型。今天,我收到了这个错误:

 Using TensorFlow backend.
Traceback (most recent call last):
File "train.py", line 6, in <module>
from yolo import create_yolov3_model, dummy_loss
File "/content/drive/MyDrive/yolo/yolo_plz_work/yolo.py", line 1, in <module>
from keras.layers import Conv2D, Input, BatchNormalization, LeakyReLU, ZeroPadding2D, UpSampling2D, Lambda
File "/usr/local/lib/python3.7/dist-packages/keras/__init__.py", line 3, in <module>
from . import utils
File "/usr/local/lib/python3.7/dist-packages/keras/utils/__init__.py", line 26, in <module>
from .vis_utils import model_to_dot
File "/usr/local/lib/python3.7/dist-packages/keras/utils/vis_utils.py", line 7, in <module>
from ..models import Model
File "/usr/local/lib/python3.7/dist-packages/keras/models.py", line 10, in <module>
from .engine.input_layer import Input
File "/usr/local/lib/python3.7/dist-packages/keras/engine/__init__.py", line 3, in <module>
from .input_layer import Input
File "/usr/local/lib/python3.7/dist-packages/keras/engine/input_layer.py", line 7, in <module>
from .base_layer import Layer
File "/usr/local/lib/python3.7/dist-packages/keras/engine/base_layer.py", line 12, in <module>
from .. import initializers
File "/usr/local/lib/python3.7/dist-packages/keras/initializers/__init__.py", line 124, in <module>
populate_deserializable_objects()
File "/usr/local/lib/python3.7/dist-packages/keras/initializers/__init__.py", line 49, in populate_deserializable_objects
LOCAL.GENERATED_WITH_V2 = tf.__internal__.tf2.enabled()
File "/usr/local/lib/python3.7/dist-packages/tensorflow_core/python/util/module_wrapper.py", line 193, in __getattr__
attr = getattr(self._tfmw_wrapped_module, name)
AttributeError: module 'tensorflow._api.v1.compat.v2' has no attribute '__internal__'
以前,事情一直很顺利,所以我不确定为什么会发生这种情况。
我使用的是 Python 3.7.10,这些是我应该使用的包:
absl-py==0.9.0
astor==0.8.1
gast==0.2.2
google-pasta==0.1.8
grpcio==1.26.0
h5py==2.10.0
Keras==2.3.1
Keras-Applications==1.0.8
Keras-Preprocessing==1.1.0
Markdown==3.1.1
numpy==1.18.1
opencv-contrib-python==4.1.2.30
opt-einsum==3.1.0
protobuf==3.11.2
PyYAML==5.3
scipy==1.4.1
six==1.14.0
tensorboard==1.15.0
tensorflow==1.15.0
tensorflow-estimator==1.15.1
termcolor==1.1.0
tqdm==4.41.1
Werkzeug==0.16.0
wrapt==1.11.2
也许 colab 最近升级了一些库?我确信我遵循了与往常相同的安装步骤。
编辑:
我认为keras版本可能存在问题。
这是我正在运行的文件的前几行:
from keras.layers import Conv2D, Input, BatchNormalization, LeakyReLU, ZeroPadding2D, UpSampling2D, Lambda
from keras.layers.merge import add, concatenate
from keras.models import Model
from keras.engine.topology import Layer
import tensorflow as tf
如果我删除所有以“from keras”开头的行,我就不会收到错误消息。但是,我以前从未接触过这些行,所以我不知道为什么它们现在会突然导致错误。另外,不是python版本导致这个错误,因为colab在4月份把它改成了3.7.10,我没问题。

最佳答案

试试这些参数,它对我有用

!pip3 uninstall keras-nightly
!pip3 uninstall -y tensorflow
!pip3 install keras==2.1.6
!pip3 install tensorflow==1.15.0
!pip3 install h5py==2.10.0

关于python - 模块 'tensorflow._api.v1.compat.v2' 没有属性 '__internal__' google colab 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67694895/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com