【发布时间】:2023-01-02 17:54:56
【问题描述】:
我正在尝试使用 ConvNextXLarge 并且我有以下代码:
model = tf.keras.applications.convnext.ConvNeXtXLarge(
model_name='convnext_xlarge',
include_top=True,
include_preprocessing=True,
weights='imagenet',
input_tensor=None,
input_shape=None,
pooling=None,
classes=1000,
classifier_activation='softmax'
)
但是我得到标题中的错误:
模块“tensorflow.keras.applications”没有属性“convnext”
我很确定这与我在 Kaggle 中使用 tensorflow v2.6 但我不知道如何升级有关
【问题讨论】:
-
对于初学者,尝试重新安装
tensorflow。使用pip uninstall tensorflow和pip install tensorflow。在您的代码中,存在拼写问题,不是ConvNeXtXLarge,而是ConvNextLarge。你的使用应该是这样的:tf.keras.applications.convnext.ConvNeXtLarge -
如果还是不行,那就尝试直接使用
from tensorflow.keras.applications import ConvNeXtLarge获取,然后使用。 -
conv-next 可能对 tf 2.10 可用,重新检查。
-
请再次尝试使用 Tensorflow 2.10 或 2.11 导入
tf.keras.applications.convnext.ConvNeXtXLargeapi。您可以使用pip install --upgrade tensorflow或提供特定版本pip install tensorflow==2.10来升级tensorflow。
标签: python tensorflow keras kaggle transfer-learning