google-research / receptive_field

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

Add "If" operation to the whitelist #8

Closed alicialitrtwe closed 3 years ago

google-cla[bot] commented 3 years ago

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

:memo: Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here with @googlebot I signed it! and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

google-cla[bot] commented 3 years ago

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

:memo: Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here with @googlebot I signed it! and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

alicialitrtwe commented 3 years ago

@googlebot I signed it!

andrefaraujo commented 3 years ago

Thanks! See the comment I left in the code.

Another questions: 1) just out of curiosity, what kind of models are you using that require this change? 2) I was able to find the PlaceholderWithDefault op, but couldn't find the "If" one. Do you know if it's related to tf.cond?

andrefaraujo commented 3 years ago

Oh, I think I know why you're adding the If op -- likely related to Keras batch-norm. You can disable it and avoid the error with the If op by doing something like this:

g = tf.Graph()
with g.as_default():
  tf.keras.backend.set_learning_phase(0) # Disable BN learning.
  x = tf.keras.Input([None, None, 3], name='input_image')
  model = tf.keras.applications.InceptionV3(input_tensor=x)
andrefaraujo commented 3 years ago

Closing due to lack of activity, but please feel free to reopen :)