Keras 简明教程
Keras - Pre-Trained Models
在本章中,我们将学习 Keras 中的预训练模型。让我们从 VGG16 开始。
In this chapter, we will learn about the pre-trained models in Keras. Let us begin with VGG16.
VGG16
VGG16 是另一个预训练模型。它也是使用 ImageNet 训练的。加载模型的语法如下:
VGG16 is another pre-trained model. It is also trained using ImageNet. The syntax to load the model is as follows −
keras.applications.vgg16.VGG16(
include_top = True,
weights = 'imagenet',
input_tensor = None,
input_shape = None,
pooling = None,
classes = 1000
)
该模型的默认输入大小为 224x224。
The default input size for this model is 224x224.
MobileNetV2
MobileNetV2 是另一个预训练模型。它也是使用 ImageNet 训练的。
MobileNetV2 is another pre-trained model. It is also trained uing ImageNet.
加载模型的语法如下:
The syntax to load the model is as follows −
keras.applications.mobilenet_v2.MobileNetV2 (
input_shape = None,
alpha = 1.0,
include_top = True,
weights = 'imagenet',
input_tensor = None,
pooling = None,
classes = 1000
)
在此,
Here,
alpha 控制网络的宽度。如果值低于 1,则减少每一层中的滤波器数量。如果值高于 1,则增加每一层中的滤波器数量。如果 alpha = 1,则每一层都使用来自论文的默认滤波器数量。
alpha controls the width of the network. If the value is below 1, decreases the number of filters in each layer. If the value is above 1, increases the number of filters in each layer. If alpha = 1, default number of filters from the paper are used at each layer.
该模型的默认输入大小为 224x224 。
The default input size for this model is 224x224.
InceptionResNetV2
InceptionResNetV2 是另一个预训练模型。它也是使用 ImageNet 训练的。加载模型的语法如下:
InceptionResNetV2 is another pre-trained model. It is also trained using ImageNet. The syntax to load the model is as follows −
keras.applications.inception_resnet_v2.InceptionResNetV2 (
include_top = True,
weights = 'imagenet',
input_tensor = None,
input_shape = None,
pooling = None,
classes = 1000)
此模型可以采用“channels_first”数据格式(通道数、高度、宽度)或“channels_last”数据格式(高度、宽度、通道数)构建。
This model and can be built both with ‘channels_first’ data format (channels, height, width) or ‘channels_last’ data format (height, width, channels).
此模型的默认输入大小为 299x299 。
The default input size for this model is 299x299.
InceptionV3
InceptionV3 是另一个预训练模型。它也是使用 ImageNet 训练的。加载模型的语法如下所示 −
InceptionV3 is another pre-trained model. It is also trained uing ImageNet. The syntax to load the model is as follows −
keras.applications.inception_v3.InceptionV3 (
include_top = True,
weights = 'imagenet',
input_tensor = None,
input_shape = None,
pooling = None,
classes = 1000
)
在此,
Here,
此模型的默认输入大小为 299x299 。
The default input size for this model is 299x299.