-
Notifications
You must be signed in to change notification settings - Fork 74k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tf2 isn't enabled in tensorflow_core.python.keras.layers.__init__ #36700
Comments
Was able to reproduce the issue. Please find the Gist here. Thanks! |
@EmGarr Importing using |
@jvishnuvardhan I do not use this layer but however all the base model of tensorflow keras do use those imports. It means that whenever you use a Resnet50 (or others) you'll use the batch normalization from tf 1.X which has a totally different behavior for trainable is False. |
I encountered this problem just yesterday when attempting to use transfer learning with pretrained models from tensorflow.keras.application-package. The validation loss and accuracy aren’t progressing as one would expect (except with VGG16 and others which don’t use BN). Still after loading the model weights I manually set this flag to be true for each BN layers and after that everything seemed to work as one would expect. |
this issue was fixed in this commit and the fix has been cherrypicked into r2.2 branch. |
System information
You can collect some of this information using our environment capture
script
You can also obtain the TensorFlow version with: 1. TF 1.0:
python -c "import tensorflow as tf; print(tf.GIT_VERSION, tf.VERSION)"
2. TF 2.0:python -c "import tensorflow as tf; print(tf.version.GIT_VERSION, tf.version.VERSION)"
Describe the current behavior
Whenever you import a layer using the path:
from tensorflow.python.keras.layers
It will import the layer using the tensorflow 1.X behavior.
Which isn't the case when we use tensorflow.keras.layers.
The issue is that every networks from tf.keras.applications (resnet, densenet...) use those import which can lead to some severe bugs (e.g: BatchNormalization).
Describe the expected behavior
Importing from
from tensorflow.python.keras.layers
andfrom tensorflow.keras.layers
should have exactly the same behavior (2.X).Code to reproduce the issue
Other info / logs
I think that the issue could be fix by changing this tensorflow_core.python.tf2.
from
to
it will make TF2_BEHAVIOR enabled by default
The text was updated successfully, but these errors were encountered: