Skip to content

Commit 712f473

Browse files
committed
Change how TF 2 is checked
The current approach checks for presence of contrib. Sometimes this is not sufficient (for e..g when testing TF 1 + enable_v2_behavior=True which is what internal tests currently do)
1 parent 32fadf0 commit 712f473

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

official/utils/misc/keras_utils.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,5 @@ def set_config_v2(enable_xla=False,
204204

205205
def is_v2_0():
206206
"""Returns true if using tf 2.0."""
207-
if hasattr(tf, 'contrib'):
208-
return False
209-
else:
210-
return True
207+
from tensorflow.python import tf2
208+
return tf2.enabled()

0 commit comments

Comments
 (0)