Hello,
Here: base_model = tf.keras.applications.MobileNetV2(input_shape=IMG_SHAPE,
include_top=True,
weights=‘imagenet’)
Why the input shape (160, 160, 3) is valid? If include_top=True, is the only valid input shape not (224, 224, 3)?
Hello,
Here: base_model = tf.keras.applications.MobileNetV2(input_shape=IMG_SHAPE,
include_top=True,
weights=‘imagenet’)
Why the input shape (160, 160, 3) is valid? If include_top=True, is the only valid input shape not (224, 224, 3)?
The include_top here is refering to the last layer of the network (mobilnet) here, it doesnt have to do with the input layer (first layer)!
Ok, so can you please explain this (from the MobileNetV2 documentation):
input_shape
: Optional shape tuple, only to be specified if include_top
is False
(otherwise the input shape has to be (224, 224, 3)
(with "channels_last"
data format) or (3, 224, 224)
(with "channels_first"
data format). It should have exactly 3 inputs channels, and width and height should be no smaller than 32. E.g. (200, 200, 3)
would be one valid value. Defaults to None
. input_shape
will be ignored if the input_tensor
is provided.
Hello, @shaya_kahn,
You may try these 3 input_shape
: (240, 240, 3), (160, 160, 3), (100, 100, 3)
and, in the model summary, examine the output shape of the last layer before the Global Average Pooling. The last input shape won’t build a model, but the first two will give you two different summarys. You see the two different summarys, then you may think from there how they are valid.
Cheers,
Raymond
Edit: The above (240, 240, 3)
was a typo and should be (224, 224, 3)
instead.
I see your point now, and to be frank I don’t know why this is happening, perhaps the model allows those shapes too…I also want to know why at this point!
Hello, Raymond
I think I now understand how to find valid input shapes. From the examples you suggested, only the (160, 160, 3) works. The other options are: 96, 128, 192, 224. Correct?
Yes, @shaya_kahn!
My (240, 240, 3) was a typo (I meant to say 224 instead of 240) , but it should be helpful to try 240, too.
These options are hard-coded in the implementation of MobileNetV2, and they correspond to different weight files, too:
Hard-coded:
Weight file name:
As for why these numbers are chosen, I believe you might have found the reason by examining the summaries
Cheers,
Raymond
So Raymond @rmwkwok the Mobilnetv2 accepts those shapes too! Strange because in Tensorflow is mentioned:
which from what I understand if include_top=True it should only accept (224, 224, 3)!
This question should be for TF’s dev team. ^^
Well, if it comes down to that, we all cool then