- Intelligent Projects Using Python
- Santanu Pattanayak
- 175字
- 2021-07-02 14:10:51
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
推薦閱讀
- Instant uTorrent
- Linux KVM虛擬化架構(gòu)實戰(zhàn)指南
- 平衡掌控者:游戲數(shù)值經(jīng)濟設(shè)計
- micro:bit魔法修煉之Mpython初體驗
- OUYA Game Development by Example
- 計算機組裝與維護(第3版)
- 超大流量分布式系統(tǒng)架構(gòu)解決方案:人人都是架構(gòu)師2.0
- 無蘋果不生活:OS X Mountain Lion 隨身寶典
- Python Machine Learning Blueprints
- FL Studio Cookbook
- 單片微機原理及應(yīng)用
- Blender 3D By Example
- Arduino項目案例:游戲開發(fā)
- 筆記本電腦維修技能實訓
- 計算機組成技術(shù)教程