#以densenet为例
model = keras.applications.densenet.DenseNet121(input_shape=(224,224,3),
weights=None,classes=100)
#对每个层添加l2正则化
for layer in model.layers:
if hasattr(layer,'kernel_regularizer'):
layer.kernel_regularizer = keras.regularizers.l2(0.001)
对keras预训练模型添加l2正则化
最新推荐文章于 2022-03-01 15:55:41 发布