This error occurred, while my original code doesn't contain 'import resnet'.
It seems like the error occurred when import 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'
the solution for tensorflow 2.4.0 is
from tensorflow.keras.applications import ResNet50
Instead of
from tensorflow.python.keras.applications.resnet import ResNet50
try this
from tensorflow.python.keras.applications.resnet50 import ResNet50
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With