- 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
推薦閱讀
- Raspberry Pi 3 Cookbook for Python Programmers
- Linux KVM虛擬化架構(gòu)實戰(zhàn)指南
- Creating Dynamic UI with Android Fragments
- Intel FPGA/CPLD設(shè)計(高級篇)
- Getting Started with Qt 5
- Learning Stencyl 3.x Game Development Beginner's Guide
- scikit-learn:Machine Learning Simplified
- Arduino BLINK Blueprints
- Building 3D Models with modo 701
- 電腦高級維修及故障排除實戰(zhàn)
- 龍芯自主可信計算及應(yīng)用
- Managing Data and Media in Microsoft Silverlight 4:A mashup of chapters from Packt's bestselling Silverlight books
- STM32自學(xué)筆記
- IP網(wǎng)絡(luò)視頻傳輸:技術(shù)、標(biāo)準(zhǔn)和應(yīng)用
- 基于網(wǎng)絡(luò)化教學(xué)的項目化單片機(jī)應(yīng)用技術(shù)