Keras Application应用
Kera的应用模块Application提供了带有预训练权重的Keras模型,这些模型可以用来进行预测、特征提取和finetune
模型的预训练权重将下载到~/.keras/models/并在载入模型时自动载入
可用的模型
应用于图像分类的模型,权重训练自ImageNet: Xception VGG16 VGG19 ResNet50 InceptionV3 InceptionResNetV2 MobileNet DenseNet NasNet MobileNetV2
Xception模型仅在TensorFlow下可用,因为它依赖的SeparableConvolution层仅在TensorFlow可用。MobileNet仅在TensorFlow下可用,因为它依赖的DepethwiseConvolution层仅在TF下可用。
模型信息
Xception模型
keras.applications.xception.Xception(include_top=True, weights='imagenet',
input_tensor=None, input_shape=None,
pooling=None, classes=1000)
Xception V1 模型, 权重由ImageNet训练而言
在ImageNet上,该模型取得了验证集top1 0.790和top5 0.945的正确率
注意,该模型目前仅能以TensorFlow为后端使用,由于它依赖于"SeparableConvolution"层,目前该模型只支持channels_last的维度顺序(width, height, channels)
默认输入图片大小为299x299
参数
include_top:是否保留顶层的3个全连接网络
weights:None代表随机初始化,即不加载预训练权重。'imagenet’代表加载预训练权重
input_tensor:可填入Keras tensor作为模型的图像输出tensor
input_shape:可选,仅当include_top=False有效,应为长为3的tuple,指明输入图片的shape,图片的宽高必须大于71,如(150,150,3)
pooling:当include_top=False时,该参数指定了池化方式。None代表不池化,最后一个卷积层的输出为4D张量。‘avg’代表全局平均池化,‘max’代表全局最大值池化。
classes:可选,图片分类的类别数,仅当include_top=True并且不加载预训练权重时可用。
返回值
Keras 模型对象
VGG16模型
keras.applications.vgg16.VGG16(include_top=True, weights='imagenet',
input_tensor=None, input_shape=None,
pooling=None,
classes=1000)
VGG16模型,权重由ImageNet训练而来
该模型再Theano和TensorFlow后端均可使用,并接受channels_first和channels_last两种输入维度顺序
模型的默认输入尺寸是224x224
参数:
include_top:是否保留顶层的3个全连接网络
weights:None代表随机初始化,即不加载预训练权重。'imagenet’代表加载预训练权重
input_tensor:可填入Keras tensor作为模型的图像输出tensor
input_shape:可选,仅当include_top=False有效,应为长为3的tuple,指明输入图片的shape,图片的宽高必须大于48,如(200,200,3)
pooling:当include_top=False时,该参数指定了池化方式。None代表不池化,最后一个卷积层的输出为4D张量。‘avg’代表全局平均池化,‘max’代表全局最大值池化。
classes:可选,图片分类的类别数,仅当include_top=True并且不加载预训练权重时可用。
返回值:
Keras 模型对象
VGG19模型
keras.applications.vgg19.VGG19(include_top=True, weights='imagenet',
input_tensor=None, input_shape=None,
pooling=None,
classes=1000)
VGG19模型,权重由ImageNet训练而来
该模型在Theano和TensorFlow后端均可使用,并接受channels_first和channels_last两种输入维度顺序
模型的默认输入尺寸是224x224
参数
include_top:是否保留顶层的3个全连接网络
weig