codecamp

Keras 应用

Keras 应用模块用于为深度神经网络提供预训练模型。Keras 模型用于预测、特征提取和微调。本章详细介绍了 Keras 应用程序。

预训练模型

训练好的模型由模型架构和模型权重两部分组成。模型权重是大文件,因此我们必须从 ImageNet 数据库下载并提取特征。下面列出了一些流行的预训练模型:

  • ResNet
  • VGG16
  • MobileNet
  • InceptionResNetV2
  • InceptionResNetV3

加载模型

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')

加载模型后,我们可以立即将其用于预测目的。让我们在接下来的章节中检查每个预训练模型。

Keras 使用 LSTM RNN 进行时间序列预测
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; }