Keras - 應用



Keras 應用模組用於為深度神經網路提供預訓練模型。Keras 模型用於預測、特徵提取和微調。本章詳細講解了 Keras 應用。

預訓練模型

訓練模型包含兩個部分:模型架構和模型權重。模型權重大,因此我們必須從 ImageNet 資料庫下載並提取特徵。一些流行的預訓練模型如下所示:

  • ResNet
  • VGG16
  • MobileNet
  • InceptionResNetV2
  • InceptionV3

載入模型

Keras 預訓練模型可以按如下所示輕鬆載入 −

import keras 
import numpy as np 

from keras.applications import vgg16, inception_v3, resnet50, mobilenet 

#Load the VGG model 
vgg_model = vgg16.VGG16(weights = 'imagenet') 

#Load the Inception_V3 model 
inception_model = inception_v3.InceptionV3(weights = 'imagenet') 

#Load the ResNet50 model 
resnet_model = resnet50.ResNet50(weights = 'imagenet') 

#Load the MobileNet model mobilenet_model = mobilenet.MobileNet(weights = 'imagenet')

載入模型後,我們可以立即使用它來進行預測。讓我們在即將到來的章節中檢查每個預訓練模型。

廣告
© . All rights reserved.