Keras 简明教程
Keras - Applications
Keras 应用程序模块用于为深度神经网络提供预训练模型。Keras 模型用于预测、特征提取和微调。本章详细解释了 Keras 应用程序。
Keras applications module is used to provide pre-trained model for deep neural networks. Keras models are used for prediction, feature extraction and fine tuning. This chapter explains about Keras applications in detail.
Pre-trained models
训练好的模型由两个部分组成,模型架构和模型权重。模型权重是大型文件,因此我们必须从 ImageNet 数据库下载和提取特征。下面列出了一些流行的预训练模型:
Trained model consists of two parts model Architecture and model Weights. Model weights are large file so we have to download and extract the feature from ImageNet database. Some of the popular pre-trained models are listed below,
-
ResNet
-
VGG16
-
MobileNet
-
InceptionResNetV2
-
InceptionV3
Loading a model
Keras 预训练模型可以轻松加载,如下所示:
Keras pre-trained models can be easily loaded as specified below −
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')
一旦加载了该模型,我们就可以立即将其用于预测目的。让我们在即将到来的章节中查看每个预训练模型。
Once the model is loaded, we can immediately use it for prediction purpose. Let us check each pre-trained model in the upcoming chapters.