google-research / receptive_field

Compute receptive fields of your favorite convnets
Apache License 2.0
431 stars 54 forks source link

Support for Mobilenetv2 #10

Open guillemdelgado opened 3 years ago

guillemdelgado commented 3 years ago

I have been working recently with Mobilenets v2 and it would be great if it was supported as v1 it is. I am using TF 1.14 and Keras 2.2.4-tf and I tried myself supporting it. I was able to return the conv_kernel_size correctly from the depthwise conv (they have another name in v2 so it was crashing). But now I am stuck when computing the get_computed_nodes as it doesn't return me the graph connections correctly.

Shall I post my changes and see from there?

andrefaraujo commented 3 years ago

Sounds good, feel free to post changes. But maybe before that: did you try computing it via the Keras Applications implementation (tf.keras.applications.mobilenet_v2), with the reference colab? Eg, just replace the call to tf.keras.applications.InceptionV3 in there.

guillemdelgado commented 3 years ago

Sounds good, feel free to post changes. But maybe before that: did you try computing it via the Keras Applications implementation (tf.keras.applications.mobilenet_v2), with the reference colab? Eg, just replace the call to tf.keras.applications.InceptionV3 in there.

I have tried it with the reference colab replacing the model with a Mobilenetv2 it does not work. However, I was able to make it work with a small change. Depthwise convolutionals have a kernel name "depthwise_kernel", while the other Conv2d have "kernel", that was why it was not working.

andrefaraujo commented 3 years ago

cool, thanks for debugging and finding the workaround :)

Feel free to send over a PR and I'd be happy to review the required changes!