gpt4 book ai didi

python - 导入错误 : cannot import name 'resnet'

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

发生此错误,而我的原始代码不包含“导入 resnet”。

似乎在导入 tensorflow 时发生了错误。

Traceback (most recent call last):
File "step2_training.py", line 5, in <module>
from class_coTrust import *
File "/share/scratch/manqingdong/my_filename/class_coTrust.py", line 1, in <module>
from utils import *
File "/share/scratch/manqingdong/my_filename/utils.py", line 7, in <module>
import tensorflow as tf
File "/usr/lib64/python3.6/site-packages/tensorflow/__init__.py", line 98, in <module>
from tensorflow_core import *
File "/usr/lib64/python3.6/site-packages/tensorflow_core/__init__.py", line 40, in <module>
from tensorflow.python.tools import module_util as _module_util
File "/usr/lib64/python3.6/site-packages/tensorflow/__init__.py", line 50, in __getattr__
module = self._load()
File "/usr/lib64/python3.6/site-packages/tensorflow/__init__.py", line 44, in _load
module = _importlib.import_module(self.__name__)
File "/usr/lib64/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "/usr/lib64/python3.6/site-packages/tensorflow_core/python/__init__.py", line 83, in <module>
from tensorflow.python import keras
File "/usr/lib64/python3.6/site-packages/tensorflow_core/python/keras/__init__.py", line 26, in <module>
from tensorflow.python.keras import activations
File "/usr/lib64/python3.6/site-packages/tensorflow_core/python/keras/__init__.py", line 27, in <module>
from tensorflow.python.keras import applications
File "/usr/lib64/python3.6/site-packages/tensorflow_core/python/keras/applications/__init__.py", line 64, in <module>
from tensorflow.python.keras.applications.resnet import ResNet50
File "/usr/lib64/python3.6/site-packages/tensorflow_core/python/keras/applications/resnet.py", line 22, in <module>
from keras_applications import resnet
ImportError: cannot import name 'resnet'

最佳答案

tensorflow 2.4.0 的解决方案是from tensorflow.keras.applications import ResNet50

关于python - 导入错误 : cannot import name 'resnet' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58817026/

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