为了训练图像分类模型(使用Keras或Tensorflow),我想使用我自己的图像数据集重新训练NASNetMobile的一定数量的层。
在本文:https://arxiv.org/pdf/1707.07012.pdf (第A.7节)中,我们可以这样理解:“此外,所有模型都使用位于网络上方2/3处的辅助分类器”。
下面是我想要进行迁移学习的NasNetMobile层:https://gist.github.com/didacroyo/a451c890b1f02822c7dd67c6f270f1d6
那么,在前面的基础上,我应该冻结底部1/3的层吗?(这是前250层)
发布于 2018-04-18 02:43:53
考虑到Aux分支的开始位置,我会尝试在activation_166之前冻结各层。如下所示:
model = NASNetLarge((img_rows, img_cols, img_channels),dropout=0.5, use_auxiliary_branch=True, include_top=True, weights=None, classes=nb_classes)
model.load_weights('weights/NASNet-large.h5', by_name=True, skip_mismatch=True)
# Freeze original layers
model.trainable = True
set_trainable = False
for layer in model.layers:
if layer.name == 'activation_166':
set_trainable = True
if set_trainable:
layer.trainable = True
else:
layer.trainable = False
print("layer {} is {}".format(layer.name, '+++trainable' if layer.trainable else '---frozen'))
https://stackoverflow.com/questions/48572918
复制相似问题