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.