如何利用Keras在ImageNet预训练模型进行迁移学习?
- 内容介绍
- 文章标签
- 相关推荐
本文共计1228个文字,预计阅读时间需要5分钟。
我这就简化这段代码,不超过100字:
pythonimport kerasimport numpy as npfrom keras.applications import vgg16, inception_v3, resnet50, mobilenet
我就废话不多说了,大家还是直接看代码吧!
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')
在以上代码中,我们首先import各种模型对应的module,然后load模型,并用ImageNet的参数初始化模型的参数。
如果不想使用ImageNet上预训练到的权重初始话模型,可以将各语句的中'imagenet'替换为'None'。
本文共计1228个文字,预计阅读时间需要5分钟。
我这就简化这段代码,不超过100字:
pythonimport kerasimport numpy as npfrom keras.applications import vgg16, inception_v3, resnet50, mobilenet
我就废话不多说了,大家还是直接看代码吧!
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')
在以上代码中,我们首先import各种模型对应的module,然后load模型,并用ImageNet的参数初始化模型的参数。
如果不想使用ImageNet上预训练到的权重初始话模型,可以将各语句的中'imagenet'替换为'None'。

