官术网_书友最值得收藏!

The InceptionV3 transfer learning network

The InceptionV3 network for our task is defined in the following code block. One thing to note is that since InceptionV3 is a much deeper network, we can have a greater number of initial layers. The idea of not training all of the layers in each of the models has another advantage, with respect to data availability. If we use less data training, the weights of the entire network might lead to overfitting. Freezing the layers reduces the number of weights to train, and hence, provides a form of regularization.

Since the initial layers learn generic features irrespective of the domain of the problem, they are the best layers to freeze. We have also used dropout in the fully connected layer, to prevent overfitting:

def inception_pseudo(dim=224,freeze_layers=30,full_freeze='N'):
model = InceptionV3(weights='imagenet',include_top=False)
x = model.output
x = GlobalAveragePooling2D()(x)
x = Dense(512, activation='relu')(x)
x = Dropout(0.5)(x)
x = Dense(512, activation='relu')(x)
x = Dropout(0.5)(x)
out = Dense(5,activation='softmax')(x)
model_final = Model(input = model.input,outputs=out)
if full_freeze != 'N':
for layer in model.layers[0:freeze_layers]:
layer.trainable = False
return model_final
主站蜘蛛池模板: 上杭县| 涞水县| 阳曲县| 靖宇县| 乐陵市| 古丈县| 宣威市| 理塘县| 上高县| 邢台市| 武山县| 金华市| 乌海市| 北京市| 临颍县| 库尔勒市| 广元市| 桓台县| 资阳市| 浦北县| 潮州市| 驻马店市| 合作市| 左贡县| 长岭县| 加查县| 犍为县| 克山县| 新乐市| 嵩明县| 图们市| 九龙县| 合江县| 金门县| 民丰县| 宝丰县| 井冈山市| 田东县| 女性| 上高县| 太和县|