这个微调在我的CNN Keras中做了什么?代码分析

2024-05-11 03:37:10 发布

您现在位置:Python中文网/ 问答频道 /正文

我需要做这段代码正在做的,关于层,权重。。在这种情况下如何进行微调。你知道吗

vgg16_model = VGG16(weights="imagenet", include_top=True)

#remove the top layer
base_model = Model(input=vgg16_model.input, 
                   output=vgg16_model.get_layer("block5_pool").output)

#attach a new top layer
base_out = base_model.output
base_out = Dropout(0.60)(base_out)
base_out = Reshape((25088,))(base_out)
fc2 = Dropout(0.60)(base_out)

top_preds = Dense(1, activation="sigmoid")(fc2)

#freeze weights until the last but one convolution layer (block4_pool)
for layer in base_model.layers[0:14]:
    layer.trainable = False

#create new hybrid model
model = Model(input=base_model.input, output=top_preds)

Tags: thelayernewinputoutputbasemodeltop