keras-team / keras-applications

Reference implementations of popular deep learning models.
Other
2k stars 910 forks source link

Missing one conv2d layer in inceptionv3? #201

Open LucaUrbinati44 opened 3 years ago

LucaUrbinati44 commented 3 years ago

Summary

I think that there is a missing layer in the implementation of Inceptionv3.

According to the paper C. Szegedy, V. Vanhoucke, S. Ioffe, J. Shlens, and Z. Wojna, “Rethinking the Inception Architecture for Computer Vision,” arXiv:1512.00567 [cs], Dec. 2015, Accessed: Dec. 30, 2020. [Online]. Available: http://arxiv.org/abs/1512.00567, in Table 1 there should be a conv2d layer that takes 35x35x192 as input and provides 35x35x288 as output.

To have a graphical view, the layer I'm point to is the sixth red conv2d block in this picture showing the architecture of Inceptionv3: https://hackmd.io/@bouteille/SkD5Xd4DL#I-Summary.

The missing layer should be place between line 175 and 176 of the file: https://github.com/keras-team/keras-applications/blob/master/keras_applications/inception_v3.py, and it should be: x = conv2d_bn(x, 288, 3, 3, padding='same')

Moreover, I don't understand why the concatenation named "mixed0" outputs 35x35x256 instead of 35x35x288. In this case the line to edit should be line 191 from this: branch_pool = conv2d_bn(branch_pool, 32, 1, 1) to this: branch_pool = conv2d_bn(branch_pool, 64, 1, 1)

Let me know if I had an hallucination or it is really missing. Thank you!!!

Environment

Logs or source codes for reproduction

import tensorflow as tf

from tensorflow.keras.applications import InceptionV3

from tensorflow.keras.models import Sequential
from tensorflow.keras import layers

IMG_SIZE = 299

def build_model():
    inputs = layers.Input(shape=(IMG_SIZE, IMG_SIZE, 3))
    model = InceptionV3(include_top=True, weights=None, input_tensor=inputs)
    optimizer = tf.keras.optimizers.Adam(learning_rate=1e-2)
    model.compile(
        optimizer=optimizer, loss="categorical_crossentropy", metrics=["accuracy"]
    )
    return model

model = build_model()
model.summary()