如果我们需要更改 input_shape,为什么我们需要 include_top=False?

Why do we need to include_top=False if we need to change the input_shape?

据我所知,输入元组是从卷积块进入的。 所以如果我们想改变 input_tuple 形状,修改卷积是有意义的。 为什么要include_top=False,去掉最后的全连接层?

另一方面,如果我们有不同数量的 类,Keras 可以选择使用 no_of_classes

更改 softmax 层

我知道是我遗漏了一些东西。请帮助我

示例:Inception Resnet V2

input_shape: optional shape tuple, only to be specified if include_top is False (otherwise the input shape has to be (299, 299, 3) (with 'channels_last' data format) or (3, 299, 299) (with 'channels_first' data format). It should have exactly 3 inputs channels, and width and height should be no smaller than 139. E.g. (150, 150, 3) would be one valid value.

include_top: whether to include the fully-connected layer at the top of the network.

https://keras.io/applications/#inceptionresnetv2

这仅仅是因为最后的全连接层只能接受固定大小的输入,这在之前已经由输入形状和卷积层中的所有处理定义。对输入形状的任何更改都会更改输入到全连接层的形状,从而使权重不兼容(矩阵大小不匹配且无法应用)。

这是全连接层的特定问题。如果再用一层做分类,比如global average pooling,就不会出现这个问题了。