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

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
主站蜘蛛池模板: 苏尼特左旗| 玛沁县| 墨玉县| 武邑县| 林西县| 洛川县| 廉江市| 永城市| 石楼县| 酉阳| 榕江县| 巴林右旗| 甘泉县| 沛县| 剑河县| 亳州市| 信丰县| 福泉市| 共和县| 余江县| 绥滨县| 临潭县| 巴彦县| 鄱阳县| 登封市| 台东县| 云阳县| 弥渡县| 胶南市| 胶州市| 鱼台县| 浮梁县| 新安县| 泗阳县| 武陟县| 高阳县| 昌宁县| 孟州市| 临潭县| 恩平市| 和静县|