微调网络的步骤如下:
现在,如果网络架构像VGG16一样简单,我们可以简单地从block5_conv1 (Conv2D)
解冻基础网络并重新训练它。
但是当架构像InceptionResnetV2一样高度复杂时,从哪里开始?有没有人有任何实践经验?在python中运行以下代码以查看模型:
from keras.applications import InceptionResNetV2
conv_base = InceptionResNetV2(weights='imagenet',
include_top=False,
input_shape=(299, 299, 3))
conv_base.summary()
from keras.utils import plot_model
plot_model(conv_base, to_file='model.png')`
答案 0 :(得分:1)
使用InceptionResNetV2对模型进行非常基本的微调将如下所示:
from inception_resnet_v2 import InceptionResNetV2
# ImageNet classification
model = InceptionResNetV2()
model.predict(...)
# Finetuning on another 100-class dataset
base_model = InceptionResNetV2(include_top=False, pooling='avg')
# The first argument in the next line represents the number of classes
outputs = Dense(100, activation='softmax')(base_model.output)
model = Model(base_model.inputs, outputs)
model.compile(...)
model.fit(...)
的好地方