Keras 中 ImageNet 模型的输出是什么?
What is the output of ImageNet model in Keras?
我正在尝试了解迁移学习。
其中一个教程代码中使用了ImageNet/MobileNetV2模型。
模型的输出为 4,4,1280
,如屏幕截图所示。
它是网络的最终输出层吗?
实际上我希望模型将 return 最后一层的输出,其维度将是模型具有的分类类型的数量。例如 1000,0,0 如果在 1000 个不同的 类 图像上训练。
这不是输出层吗?或者是?
此外,我所指的代码已将 GlobalAveragePooling
应用于此 (4,4,1280)
层?
我们为什么要这样做?
Is it the final output layer of the network?
没有。加载模型时,使用了 include_top=False
。这意味着我们只需要用于迁移学习问题的特征提取器(不需要与针对不同问题训练的顶部分类层一起使用)。我们希望在该问题中提取特征所获得的知识对我们的问题有用。
base_model = tf.keras.applications.MobileNetV2(input_shape=IMG_SHAPE,
include_top=False,
weights='imagenet')
Actually I was hoping that the model will return the final layer's output, whose dimensions will be number of classification types the model has. e.g 1000,0,0 if trained on 1000 different classes of images.
如果我们如下加载模型 (include_top=True
),我们可以看到输出现在有 1000 个维度。
base_model = tf.keras.applications.MobileNetV2(input_shape=IMG_SHAPE,
include_top=True,
weights='imagenet')
base_mode.output
<tf.Tensor 'Logits/Identity:0' shape=(None, 1000) dtype=float32>
So is this not the output layer? Or is it?
您示例中的那个不是 - 它被称为瓶颈层。我上面的那个例子是.
Also, the code I am referring to, applied GlobalAveragePooling to this (4,4,1280) layer? Why do we do this?
这是将我们自己的分类器附加到特征提取器的第一步,特征提取器通常层数较少,并以我们问题中的 类 数量结束。训练时,我们会冻结特征提取器(大多数时候)并只训练新添加的分类器。 fine tuning时,bottleneck layer中的几层会被解冻并重新训练。
我正在尝试了解迁移学习。
其中一个教程代码中使用了ImageNet/MobileNetV2模型。
模型的输出为 4,4,1280
,如屏幕截图所示。
它是网络的最终输出层吗?
实际上我希望模型将 return 最后一层的输出,其维度将是模型具有的分类类型的数量。例如 1000,0,0 如果在 1000 个不同的 类 图像上训练。
这不是输出层吗?或者是?
此外,我所指的代码已将 GlobalAveragePooling
应用于此 (4,4,1280)
层?
我们为什么要这样做?
Is it the final output layer of the network?
没有。加载模型时,使用了 include_top=False
。这意味着我们只需要用于迁移学习问题的特征提取器(不需要与针对不同问题训练的顶部分类层一起使用)。我们希望在该问题中提取特征所获得的知识对我们的问题有用。
base_model = tf.keras.applications.MobileNetV2(input_shape=IMG_SHAPE,
include_top=False,
weights='imagenet')
Actually I was hoping that the model will return the final layer's output, whose dimensions will be number of classification types the model has. e.g 1000,0,0 if trained on 1000 different classes of images.
如果我们如下加载模型 (include_top=True
),我们可以看到输出现在有 1000 个维度。
base_model = tf.keras.applications.MobileNetV2(input_shape=IMG_SHAPE,
include_top=True,
weights='imagenet')
base_mode.output
<tf.Tensor 'Logits/Identity:0' shape=(None, 1000) dtype=float32>
So is this not the output layer? Or is it?
您示例中的那个不是 - 它被称为瓶颈层。我上面的那个例子是.
Also, the code I am referring to, applied GlobalAveragePooling to this (4,4,1280) layer? Why do we do this?
这是将我们自己的分类器附加到特征提取器的第一步,特征提取器通常层数较少,并以我们问题中的 类 数量结束。训练时,我们会冻结特征提取器(大多数时候)并只训练新添加的分类器。 fine tuning时,bottleneck layer中的几层会被解冻并重新训练。