我正在尝试在 Conda 环境中的 Jupyter Notebooks 上运行 ResNet152。这是我的代码:从 tensorflow.keras.applications 导入 ResNet50、ResNet101、ResNet152、InceptionResNetV2、DenseNet12...
我正在尝试在 Conda 环境中的 Jupyter Notebook 上运行 ResNet152。这是我的代码:
from tensorflow.keras.applications import ResNet50, ResNet101, ResNet152, InceptionResNetV2, DenseNet121
from tensorflow.keras.models import Model
from tensorflow.keras.layers import Dense, GlobalAveragePooling2D, Activation, BatchNormalization
from tensorflow.keras import mixed_precision, layers, models
import tensorflow as tf
from tensorflow.keras.optimizers.schedules import ExponentialDecay
from tensorflow.keras.optimizers import Adam, RMSprop
mixed_precision.set_global_policy('mixed_float16')
base_model = ResNet152(weights='imagenet', include_top=False, input_shape=(256, 256, 3))
for layer in base_model.layers:
layer.trainable = True
pooling_layer = layers.GlobalAveragePooling2D()(base_model.output) # GlobalAveragePooling2D layer
output_layer = layers.Dense(1, activation='sigmoid', name='output_layer')(pooling_layer)
model = Model(inputs=base_model.input, outputs=output_layer)
initial_learning_rate = 0.001
lr_schedule = ExponentialDecay(
initial_learning_rate,
decay_steps=50, # Adjust the decay steps as needed
decay_rate=0.9, # Adjust the decay rate as needed
staircase=False)
optimizer = Adam(learning_rate=lr_schedule)
model.compile(
optimizer=optimizer,
loss='binary_crossentropy',
metrics=['accuracy', tf.keras.metrics.Precision(), tf.keras.metrics.Recall(), tf.keras.metrics.AUC(name='auc')]
)
model.summary()
os.environ['CUDA_VISIBLE_DEVICES'] = '0'
history = model.fit(dataset_batched_withoutnames, epochs=5)
我收到以下错误:
DNN library is not found.
[[{{node model/conv1_conv/Conv2D}}]] [Op:__inference_train_function_55822]
(有一个长框,但没有将其全部复制粘贴)
我回去降级了我的 Tensorflow、CUDA 和 cuDNN。我现在使用的是 CUDA 11.2、cuDNN 8.1.0 和 Tensorflow 2.10.0
我回到我的路径并清理了所有内容,并将以下所有内容添加到路径中
这为什么不起作用?
Tensorflow、CUDA、cuDNN 上的机器学习模型不起作用
下载声明:
本站所有软件和资料均为软件作者提供或网友推荐发布而来,仅供学习和研究使用,不得用于任何商业用途。如本站不慎侵犯你的版权请联系我,我将及时处理,并撤下相关内容!