codecamp

Keras 预训练模型

在本章中,我们将了解 Keras 中的预训练模型。让我们从 VGG16 开始。

VGG16

VGG16 是另一个预训练模型。它还使用 ImageNet 进行训练。加载模型的语法如下:

keras.applications.vgg16.VGG16(
   include_top = True,
   weights = 'imagenet',
   input_tensor = None,
   input_shape = None,
   pooling = None,
   classes = 1000
)

此模型的默认输入大小为 224x224

MobileNetV2

MobileNetV2 是另一个预训练模型。它也是使用ImageNet 进行训练。 加载模型的语法如下:

keras.applications.mobilenet_v2.MobileNetV2 (
   input_shape = None, 
   alpha = 1.0, 
   include_top = True, 
   weights = 'imagenet', 
   input_tensor = None, 
   pooling = None, 
   classes = 1000
)

alpha控制网络的宽度。如果该值低于 1,则减少每层中的过滤器数量。如果该值大于 1,则增加每层中的过滤器数量。如果 alpha = 1,则在每一层使用纸张的默认过滤器数量。

此模型的默认输入大小为224x224

InceptionResNetV2

InceptionResNetV2 是另一个预训练模型。它也是使用ImageNet 进行训练。加载模型的语法如下:

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”数据格式(高度、宽度、通道)构建。

此模型的默认输入大小为299x299

InceptionV3

InceptionV3 是另一个预训练模型。它也是使用ImageNet 进行训练。加载模型的语法如下:

keras.applications.inception_v3.InceptionV3 (
   include_top = True, 
   weights = 'imagenet', 
   input_tensor = None, 
   input_shape = None, 
   pooling = None, 
   classes = 1000
)

此模型的默认输入大小为299x299

结论

Keras 非常简单、可扩展且易于实现神经网络 API,可用于构建具有高级抽象的深度学习应用程序。Keras 是深度学习模型的最佳选择。

Keras 使用 ResNet 模型进行实时预测
温馨提示
下载编程狮App,免费阅读超1000+编程语言教程
取消
确定
目录

关闭

MIP.setData({ 'pageTheme' : getCookie('pageTheme') || {'day':true, 'night':false}, 'pageFontSize' : getCookie('pageFontSize') || 20 }); MIP.watch('pageTheme', function(newValue){ setCookie('pageTheme', JSON.stringify(newValue)) }); MIP.watch('pageFontSize', function(newValue){ setCookie('pageFontSize', newValue) }); function setCookie(name, value){ var days = 1; var exp = new Date(); exp.setTime(exp.getTime() + days*24*60*60*1000); document.cookie = name + '=' + value + ';expires=' + exp.toUTCString(); } function getCookie(name){ var reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)'); return document.cookie.match(reg) ? JSON.parse(document.cookie.match(reg)[2]) : null; }