您当前的位置:首页 > IT编程 > 深度学习
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch |

自学教程:Keras 的预训练权值模型用来进行预测、特征提取和微调(fine-tuning)

51自学网 2022-12-09 16:44:28
  深度学习
这篇教程Keras 的预训练权值模型用来进行预测、特征提取和微调(fine-tuning)写得很实用,希望能帮到您。

Keras 的预训练权值模型用来进行预测、特征提取和微调(fine-tuning)

 
 

转至:Keras中文文档 https://keras.io/zh/applications/

应用 Applications

Keras 的应用模块(keras.applications)提供了带有预训练权值的深度学习模型,这些模型可以用来进行预测、特征提取和微调(fine-tuning)。

当你初始化一个预训练模型时,会自动下载权重到 ~/.keras/models/ 目录下。

可用的模型

在 ImageNet 上预训练过的用于图像分类的模型:

所有的这些架构都兼容所有的后端 (TensorFlow, Theano 和 CNTK),并且会在实例化时,根据 Keras 配置文件〜/.keras/keras.json 中设置的图像数据格式构建模型。举个例子,如果你设置 image_data_format=channels_last,则加载的模型将按照 TensorFlow 的维度顺序来构造,即「高度-宽度-深度」(Height-Width-Depth)的顺序。

注意:

  • 对于 Keras < 2.2.0,Xception 模型仅适用于 TensorFlow,因为它依赖于 SeparableConvolution层。
  • 对于 Keras < 2.1.5,MobileNet 模型仅适用于 TensorFlow,因为它依赖于 DepthwiseConvolution层。

图像分类模型的使用示例

使用 ResNet50 进行 ImageNet 分类

from keras.applications.resnet50 import ResNet50
from keras.preprocessing import image
from keras.applications.resnet50 import preprocess_input, decode_predictions
import numpy as np

model = ResNet50(weights='imagenet')

img_path = 'elephant.jpg'
img = image.load_img(img_path, target_size=(224, 224))
x = image.img_to_array(img)
x = np.expand_dims(x, axis=0)
x = preprocess_input(x)

preds = model.predict(x)
# 将结果解码为元组列表 (class, description, probability)
# (一个列表代表批次中的一个样本)
print('Predicted:', decode_predictions(preds, top=3)[0])
# Predicted: [(u'n02504013', u'Indian_elephant', 0.82658225), (u'n01871265', u'tusker', 0.1122357), (u'n02504458', u'African_elephant', 0.061040461)]

使用 VGG16 提取特征

from keras.applications.vgg16 import VGG16
from keras.preprocessing import image
from keras.applications.vgg16 import preprocess_input
import numpy as np

model = VGG16(weights='imagenet', include_top=False)#include_top=False 去掉最后3层的全连接层

img_path = 'elephant.jpg'
img = image.load_img(img_path, target_size=(224, 224))
x = image.img_to_array(img)
x = np.expand_dims(x, axis=0)
x = preprocess_input(x)

features = model.predict(x)

从VGG19 的任意中间层中抽取特征

from keras.applications.vgg19 import VGG19
from keras.preprocessing import image
from keras.applications.vgg19 import preprocess_input
from keras.models import Model
import numpy as np

base_model = VGG19(weights='imagenet')
model = Model(inputs=base_model.input, outputs=base_model.get_layer('block4_pool').output)

img_path = 'elephant.jpg'
img = image.load_img(img_path, target_size=(224, 224))
x = image.img_to_array(img)
x = np.expand_dims(x, axis=0)
x = preprocess_input(x)

block4_pool_features = model.predict(x)

在新类上微调 InceptionV3

from keras.applications.inception_v3 import InceptionV3
from keras.preprocessing import image
from keras.models import Model
from keras.layers import Dense, GlobalAveragePooling2D
from keras import backend as K

# 构建不带分类器的预训练模型
base_model = InceptionV3(weights='imagenet', include_top=False)

# 添加全局平均池化层
x = base_model.output
x = GlobalAveragePooling2D()(x)

# 添加一个全连接层
x = Dense(1024, activation='relu')(x)

# 添加一个分类器,假设我们有200个类
predictions = Dense(200, activation='softmax')(x)

# 构建我们需要训练的完整模型
model = Model(inputs=base_model.input, outputs=predictions)

# 首先,我们只训练顶部的几层(随机初始化的层)
# 锁住所有 InceptionV3 的卷积层
for layer in base_model.layers:
    layer.trainable = False

# 编译模型(一定要在锁层以后操作)
model.compile(optimizer='rmsprop', loss='categorical_crossentropy')

# 在新的数据集上训练几代
model.fit_generator(...)

# 现在顶层应该训练好了,让我们开始微调 Inception V3 的卷积层。
# 我们会锁住底下的几层,然后训练其余的顶层。

# 让我们看看每一层的名字和层号,看看我们应该锁多少层呢:
for i, layer in enumerate(base_model.layers):
   print(i, layer.name)

# 我们选择训练最上面的两个 Inception block
# 也就是说锁住前面249层,然后放开之后的层。
for layer in model.layers[:249]:
   layer.trainable = False
for layer in model.layers[249:]:
   layer.trainable = True

# 我们需要重新编译模型,才能使上面的修改生效
# 让我们设置一个很低的学习率,使用 SGD 来微调
from keras.optimizers import SGD
model.compile(optimizer=SGD(lr=0.0001, momentum=0.9), loss='categorical_crossentropy')

# 我们继续训练模型,这次我们训练最后两个 Inception block
# 和两个全连接层
model.fit_generator(...)

通过自定义输入张量构建 InceptionV3

from keras.applications.inception_v3 import InceptionV3
from keras.layers import Input

# 这也可能是不同的 Keras 模型或层的输出
input_tensor = Input(shape=(224, 224, 3))  # 假定 K.image_data_format() == 'channels_last'

model = InceptionV3(input_tensor=input_tensor, weights='imagenet', include_top=True)

 

模型概览

模型 大小 Top-1 准确率 Top-5 准确率 参数数量 深度
Xception 88 MB 0.790 0.945 22,910,480 126
VGG16 528 MB 0.713 0.901 138,357,544 23
VGG19 549 MB 0.713 0.900 143,667,240 26
ResNet50 99 MB 0.749 0.921 25,636,712 168
InceptionV3 92 MB 0.779 0.937 23,851,784 159
InceptionResNetV2 215 MB 0.803 0.953 55,873,736 572
MobileNet 16 MB 0.704 0.895 4,253,864 88
MobileNetV2 14 MB 0.713 0.901 3,538,984 88
DenseNet121 33 MB 0.750 0.923 8,062,504 121
DenseNet169 57 MB 0.762 0.932 14,307,880 169
DenseNet201 80 MB 0.773 0.936 20,242,984 201
NASNetMobile 23 MB 0.744 0.919 5,326,716 -
NASNetLarge 343 MB 0.825 0.960 88,949,818 -

Top-1 准确率和 Top-5 准确率都是在 ImageNet 验证集上的结果。

 

Xception

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

在 ImageNet 上预训练的 Xception V1 模型。

在 ImageNet 上,该模型取得了验证集 top1 0.790 和 top5 0.945 的准确率。

注意该模型只支持 channels_last 的维度顺序(高度、宽度、通道)。

模型默认输入尺寸是 299x299。

参数

  • include_top: 是否包括顶层的全连接层。
  • weights: None 代表随机初始化, 'imagenet' 代表加载在 ImageNet 上预训练的权值。
  • input_tensor: 可选,Keras tensor 作为模型的输入(即 layers.Input() 输出的 tensor)。
  • input_shape: 可选,输入尺寸元组,仅当 include_top=False 时有效(否则输入形状必须是 (299, 299, 3),因为预训练模型是以这个大小训练的)。它必须拥有 3 个输入通道,且宽高必须不小于 71。例如 (150, 150, 3) 是一个合法的输入尺寸。
  • pooling: 可选,当 include_topFalse 时,该参数指定了特征提取时的池化方式。
    • None 代表不池化,直接输出最后一层卷积层的输出,该输出是一个 4D 张量。
    • 'avg' 代表全局平均池化(GlobalAveragePooling2D),相当于在最后一层卷积层后面再加一层全局平均池化层,输出是一个 2D 张量。
    • 'max' 代表全局最大池化。
  • classes: 可选,图片分类的类别数,仅当 include_topTrue 并且不加载预训练权值时可用。

返回值

一个 Keras Model 对象.

参考文献

License

预训练权值由我们自己训练而来,基于 MIT license 发布。

 

VGG16

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

VGG16 模型,权值由 ImageNet 训练而来。

该模型可同时构建于 channels_first (通道,高度,宽度) 和 channels_last (高度,宽度,通道)两种输入维度顺序。

模型默认输入尺寸是 224x224。

参数

  • include_top: 是否包括顶层的全连接层。
  • weights: None 代表随机初始化, 'imagenet' 代表加载在 ImageNet 上预训练的权值。
  • input_tensor: 可选,Keras tensor 作为模型的输入(即 layers.Input() 输出的 tensor)。
  • input_shape: 可选,输入尺寸元组,仅当 include_top=False 时有效,否则输入形状必须是 (244, 244, 3)(对于 channels_last 数据格式),或者 (3, 244, 244)(对于 channels_first 数据格式)。它必须拥有 3 个输入通道,且宽高必须不小于 32。例如 (200, 200, 3) 是一个合法的输入尺寸。
  • pooling: 可选,当 include_topFalse 时,该参数指定了特征提取时的池化方式。
    • None 代表不池化,直接输出最后一层卷积层的输出,该输出是一个四维张量。
    • 'avg' 代表全局平均池化(GlobalAveragePooling2D),相当于在最后一层卷积层后面再加一层全局平均池化层,输出是一个二维张量。
    • 'max' 代表全局最大池化
  • classes: 可选,图片分类的类别数,仅当 include_topTrue 并且不加载预训练权值时可用。

返回值

一个 Keras Model 对象。

参考文献

License

预训练权值由 VGG at Oxford 发布的预训练权值移植而来,基于 Creative Commons Attribution License

 

VGG19

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

VGG19 模型,权值由 ImageNet 训练而来。

该模型可同时构建于 channels_first (通道,高度,宽度) 和 channels_last(高度,宽度,通道)两种输入维度顺序。

模型默认输入尺寸是 224x224。

参数

  • include_top: 是否包括顶层的全连接层。
  • weights: None 代表随机初始化, 'imagenet' 代表加载在 ImageNet 上预训练的权值。
  • input_tensor: 可选,Keras tensor 作为模型的输入(即 layers.Input() 输出的 tensor)。
  • input_shape: 可选,输入尺寸元组,仅当 include_top=False 时有效,否则输入形状必须是 (244, 244, 3)(对于 channels_last 数据格式),或者 (3, 244, 244)(对于 channels_first 数据格式)。它必须拥有 3 个输入通道,且宽高必须不小于 32。例如 (200, 200, 3) 是一个合法的输入尺寸。
  • pooling: 可选,当 include_topFalse 时,该参数指定了特征提取时的池化方式。
    • None 代表不池化,直接输出最后一层卷积层的输出,该输出是一个四维张量。
    • 'avg' 代表全局平均池化(GlobalAveragePooling2D),相当于在最后一层卷积层后面再加一层全局平均池化层,输出是一个二维张量。
    • 'max' 代表全局最大池化
  • classes: 可选,图片分类的类别数,仅当 include_topTrue 并且不加载预训练权值时可用。

返回值

一个 Keras Model 对象。

参考文献

License

预训练权值由 VGG at Oxford 发布的预训练权值移植而来,基于 Creative Commons Attribution License

 

ResNet50

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

ResNet50 模型,权值由 ImageNet 训练而来。

该模型可同时构建于 channels_first (通道,高度,宽度) 和 channels_last(高度,宽度,通道)两种输入维度顺序。

模型默认输入尺寸是 224x224。

参数

  • include_top: 是否包括顶层的全连接层。
  • weights: None 代表随机初始化, 'imagenet' 代表加载在 ImageNet 上预训练的权值。
  • input_tensor: 可选,Keras tensor 作为模型的输入(即 layers.Input() 输出的 tensor)。
  • input_shape: 可选,输入尺寸元组,仅当 include_top=False 时有效,否则输入形状必须是 (244, 244, 3)(对于 channels_last 数据格式),或者 (3, 244, 244)(对于 channels_first 数据格式)。它必须拥有 3 个输入通道,且宽高必须不小于 32。例如 (200, 200, 3) 是一个合法的输入尺寸。
  • pooling: 可选,当 include_topFalse 时,该参数指定了特征提取时的池化方式。
    • None 代表不池化,直接输出最后一层卷积层的输出,该输出是一个四维张量。
    • 'avg' 代表全局平均池化(GlobalAveragePooling2D),相当于在最后一层卷积层后面再加一层全局平均池化层,输出是一个二维张量。
    • 'max' 代表全局最大池化
  • classes: 可选,图片分类的类别数,仅当 include_topTrue 并且不加载预训练权值时可用。

返回值

一个 Keras Model 对象。

参考文献

License

预训练权值由 Kaiming He 发布的预训练权值移植而来,基于 MIT license

 

InceptionV3

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

Inception V3 模型,权值由 ImageNet 训练而来。

该模型可同时构建于 channels_first (通道,高度,宽度) 和 channels_last(高度,宽度,通道)两种输入维度顺序。

模型默认输入尺寸是 299x299。

参数

  • include_top: 是否包括顶层的全连接层。
  • weights: None 代表随机初始化, 'imagenet' 代表加载在 ImageNet 上预训练的权值。
  • input_tensor: 可选,Keras tensor 作为模型的输入(即 layers.Input() 输出的 tensor)。
  • input_shape: 可选,输入尺寸元组,仅当 include_top=False 时有效,否则输入形状必须是 (299, 299, 3)(对于 channels_last 数据格式),或者 (3, 299, 299)(对于 channels_first 数据格式)。它必须拥有 3 个输入通道,且宽高必须不小于 139。例如 (150, 150, 3) 是一个合法的输入尺寸。
  • pooling: 可选,当 include_topFalse 时,该参数指定了特征提取时的池化方式。
    • None 代表不池化,直接输出最后一层卷积层的输出,该输出是一个四维张量。
    • 'avg' 代表全局平均池化(GlobalAveragePooling2D),相当于在最后一层卷积层后面再加一层全局平均池化层,输出是一个二维张量。
    • 'max' 代表全局最大池化
  • classes: 可选,图片分类的类别数,仅当 include_topTrue 并且不加载预训练权值时可用。

返回值

一个 Keras Model 对象。

参考文献

License

预训练权值基于 Apache License

 

InceptionResNetV2

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

Inception-ResNet V2 模型,权值由 ImageNet 训练而来。

该模型可同时构建于 channels_first (通道,高度,宽度) 和 channels_last(高度,宽度,通道)两种输入维度顺序。

模型默认输入尺寸是 299x299。

参数

  • include_top: 是否包括顶层的全连接层。
  • weights: None 代表随机初始化, 'imagenet' 代表加载在 ImageNet 上预训练的权值。
  • input_tensor: 可选,Keras tensor 作为模型的输入(即 layers.Input() 输出的 tensor)。
  • input_shape: 可选,输入尺寸元组,仅当 include_top=False 时有效,否则输入形状必须是 (299, 299, 3)(对于 channels_last 数据格式),或者 (3, 299, 299)(对于 channels_first 数据格式)。它必须拥有 3 个输入通道,且宽高必须不小于 139。例如 (150, 150, 3) 是一个合法的输入尺寸。
  • pooling: 可选,当 include_topFalse 时,该参数指定了特征提取时的池化方式。
    • None 代表不池化,直接输出最后一层卷积层的输出,该输出是一个四维张量。
    • 'avg' 代表全局平均池化(GlobalAveragePooling2D),相当于在最后一层卷积层后面再加一层全局平均池化层,输出是一个二维张量。
    • 'max' 代表全局最大池化
  • classes: 可选,图片分类的类别数,仅当 include_topTrue 并且不加载预训练权值时可用。

返回值

一个 Keras Model 对象。

参考文献

License

预训练权值基于 Apache License

 

MobileNet

keras.applications.mobilenet.MobileNet(input_shape=None, alpha=1.0, depth_multiplier=1, dropout=1e-3, include_top=True, weights='imagenet', input_tensor=None, pooling=None, classes=1000)

在 ImageNet 上预训练的 MobileNet 模型。

注意,该模型目前只支持 channels_last 的维度顺序(高度、宽度、通道)。

模型默认输入尺寸是 224x224。

参数

  • input_shape: 可选,输入尺寸元组,仅当 include_top=False 时有效,否则输入形状必须是 (224, 224, 3)channels_last 格式)或 (3, 224, 224)channels_first 格式)。它必须为 3 个输入通道,且宽高必须不小于 32,比如 (200, 200, 3) 是一个合法的输入尺寸。
  • alpha: 控制网络的宽度:
    • 如果 alpha < 1.0,则同比例减少每层的滤波器个数。
    • 如果 alpha > 1.0,则同比例增加每层的滤波器个数。
    • 如果 alpha = 1,使用论文默认的滤波器个数
  • depth_multiplier: depthwise卷积的深度乘子,也称为(分辨率乘子)
  • dropout: dropout 概率
  • include_top: 是否包括顶层的全连接层。
  • weights: None 代表随机初始化, 'imagenet' 代表加载在 ImageNet 上预训练的权值。
  • input_tensor: 可选,Keras tensor 作为模型的输入(比如 layers.Input() 输出的 tensor)。
  • pooling: 可选,当 include_topFalse 时,该参数指定了特征提取时的池化方式。
    • None 代表不池化,直接输出最后一层卷积层的输出,该输出是一个四维张量。
    • 'avg' 代表全局平均池化(GlobalAveragePooling2D),相当于在最后一层卷积层后面再加一层全局平均池化层,输出是一个二维张量。
    • 'max' 代表全局最大池化
  • classes: 可选,图片分类的类别数,仅当 include_topTrue 并且不加载预训练权值时可用。

返回

一个 Keras Model 对象。

参考文献

License

预训练权值基于 Apache License

 

DenseNet

keras.applications.densenet.DenseNet121(include_top=True, weights='imagenet', input_tensor=None, input_shape=None, pooling=None, classes=1000)
keras.applications.densenet.DenseNet169(include_top=True, weights='imagenet', input_tensor=None, input_shape=None, pooling=None, classes=1000)
keras.applications.densenet.DenseNet201(include_top=True, weights='imagenet', input_tensor=None, input_shape=None, pooling=None, classes=1000)

在 ImageNet 上预训练的 DenseNet 模型。

该模型可同时构建于 channels_first (通道,高度,宽度) 和 channels_last(高度,宽度,通道)两种输入维度顺序。

模型默认输入尺寸是 224x224。

参数

  • blocks: 四个 Dense Layers 的 block 数量。
  • include_top: 是否包括顶层的全连接层。
  • weights: None 代表随机初始化, 'imagenet' 代表加载在 ImageNet 上预训练的权值。
  • input_tensor: 可选,Keras tensor 作为模型的输入(比如 layers.Input() 输出的 tensor)。
  • input_shape: 可选,输入尺寸元组,仅当 include_top=False 时有效(不然输入形状必须是 (224, 224, 3)channels_last 格式)或 (3, 224, 224)channels_first 格式),因为预训练模型是以这个大小训练的)。它必须为 3 个输入通道,且宽高必须不小于 32,比如 (200, 200, 3) 是一个合法的输入尺寸。
  • pooling: 可选,当 include_topFalse 时,该参数指定了特征提取时的池化方式。
    • None 代表不池化,直接输出最后一层卷积层的输出,该输出是一个四维张量。
    • 'avg' 代表全局平均池化(GlobalAveragePooling2D),相当于在最后一层卷积层后面再加一层全局平均池化层,输出是一个二维张量。
    • 'max' 代表全局最大池化.
  • classes: 可选,图片分类的类别数,仅当 include_topTrue 并且不加载预训练权值时可用。

返回

一个 Keras Model 对象。

参考文献

Licence

预训练权值基于 BSD 3-clause License

 

NASNet

keras.applications.nasnet.NASNetLarge(input_shape=None, include_top=True, weights='imagenet', input_tensor=None, pooling=None, classes=1000)
keras.applications.nasnet.NASNetMobile(input_shape=None, include_top=True, weights='imagenet', input_tensor=None, pooling=None, classes=1000)

在 ImageNet 上预训练的神经结构搜索网络模型(NASNet)。

NASNetLarge 模型默认的输入尺寸是 331x331,NASNetMobile 模型默认的输入尺寸是 224x224。

参数

  • input_shape: 可选,输入尺寸元组,仅当 include_top=False 时有效,否则对于 NASNetMobile 模型来说,输入形状必须是 (224, 224, 3)channels_last 格式)或 (3, 224, 224)channels_first 格式),对于 NASNetLarge 来说,输入形状必须是 (331, 331, 3)channels_last 格式)或 (3, 331, 331)channels_first 格式)。它必须为 3 个输入通道,且宽高必须不小于 32,比如 (200, 200, 3) 是一个合法的输入尺寸。
  • include_top: 是否包括顶层的全连接层。
  • weights: None 代表随机初始化, 'imagenet' 代表加载在 ImageNet 上预训练的权值。
  • input_tensor: 可选,Keras tensor 作为模型的输入(比如 layers.Input() 输出的 tensor)。
  • pooling: 可选,当 include_topFalse 时,该参数指定了特征提取时的池化方式。
    • None 代表不池化,直接输出最后一层卷积层的输出,该输出是一个四维张量。
    • 'avg' 代表全局平均池化(GlobalAveragePooling2D),相当于在最后一层卷积层后面再加一层全局平均池化层,输出是一个二维张量。
    • 'max' 代表全局最大池化
  • classes: 可选,图片分类的类别数,仅当 include_topTrue 并且不加载预训练权值时可用。

返回

一个 Keras Model 实例。

参考文献

License

预训练权值基于 Apache License

 

MobileNetV2

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

在 ImageNet 上预训练的 MobileNetV2 模型。

请注意,该模型仅支持 'channels_last' 数据格式(高度,宽度,通道)。

模型默认输出尺寸为 224x224。

参数

  • input_shape: optional shape tuple, to be specified if you would like to use a model with an input img resolution that is not (224, 224, 3). It should have exactly 3 inputs channels (224, 224, 3). You can also omit this option if you would like to infer input_shape from an input_tensor. If you choose to include both input_tensor and input_shape then input_shape will be used if they match, if the shapes do not match then we will throw an error. E.g. (160, 160, 3) would be one valid value.
  • alpha: 控制网络的宽度。这在 MobileNetV2 论文中被称作宽度乘子。
    • 如果 alpha < 1.0,则同比例减少每层的滤波器个数。
    • 如果 alpha > 1.0,则同比例增加每层的滤波器个数。
    • 如果 alpha = 1,使用论文默认的滤波器个数。
  • depth_multiplier: depthwise 卷积的深度乘子,也称为(分辨率乘子)
  • include_top: 是否包括顶层的全连接层。
  • weights: None 代表随机初始化,'imagenet' 代表加载在 ImageNet 上预训练的权值。
  • input_tensor: 可选,Keras tensor 作为模型的输入(即 layers.Input() 输出的 tensor)。
  • pooling: 可选,当 include_topFalse 时,该参数指定了特征提取时的池化方式。
    • None 代表不池化,直接输出最后一层卷积层的输出,该输出是一个四维张量。
    • 'avg' 代表全局平均池化(GlobalAveragePooling2D),相当于在最后一层卷积层后面再加一层全局平均池化层,输出是一个二维张量。
    • 'max' 代表全局最大池化
  • classes: 可选,图片分类的类别数,仅当 include_topTrue 并且不加载预训练权值时可用。

返回

一个 Keras model 实例。

异常

ValueError: 如果 weights 参数非法,或非法的输入尺寸,或者当 weights='imagenet' 时,非法的 depth_multiplier, alpha, rows。


返回列表
Keras CAM实现-绘制CNN每层的类激活图(CAM)
51自学网,即我要自学网,自学EXCEL、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。
京ICP备13026421号-1