- 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
推薦閱讀
- Intel FPGA/CPLD設(shè)計(jì)(基礎(chǔ)篇)
- Learning AngularJS Animations
- 電腦組裝與維修從入門到精通(第2版)
- Learning Game Physics with Bullet Physics and OpenGL
- 計(jì)算機(jī)組裝與維修技術(shù)
- 面向?qū)ο蠓治雠c設(shè)計(jì)(第3版)(修訂版)
- 單片機(jī)系統(tǒng)設(shè)計(jì)與開(kāi)發(fā)教程
- Source SDK Game Development Essentials
- Spring Cloud微服務(wù)和分布式系統(tǒng)實(shí)踐
- 基于PROTEUS的電路設(shè)計(jì)、仿真與制板
- 數(shù)字媒體專業(yè)英語(yǔ)(第2版)
- Arduino項(xiàng)目開(kāi)發(fā):智能生活
- USB應(yīng)用開(kāi)發(fā)寶典
- The Machine Learning Workshop
- 計(jì)算機(jī)組裝與維護(hù)立體化教程(微課版)