From 2fdf78a0a58e67a83c834287ea8bdfc40f948a67 Mon Sep 17 00:00:00 2001 From: NihalHarish Date: Sat, 19 Sep 2020 21:51:39 -0700 Subject: [PATCH 1/2] ref deprecation --- smdebug/tensorflow/keras.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/smdebug/tensorflow/keras.py b/smdebug/tensorflow/keras.py index 67d325d87..f8356e969 100644 --- a/smdebug/tensorflow/keras.py +++ b/smdebug/tensorflow/keras.py @@ -146,13 +146,22 @@ def _get_matching_collections( if match_inc(ts_name, current_coll.include_regex): # In TF 2.x eager mode, we can't put tensors in a set/dictionary as tensor.__hash__() - # is no longer available. tensor.experimental_ref() returns a hashable reference + # is no longer available. tensor.ref() returns a hashable reference # object to this Tensor. if is_tf_version_2x() and tf.executing_eagerly(): - # tensor.experimental_ref is an experimental API - # and can be changed or removed. - # Ref: https://www.tensorflow.org/api_docs/python/tf/Tensor#experimental_ref - tensor = tensor.experimental_ref() + if hasattr(tensor, "ref"): + # See: https://www.tensorflow.org/api_docs/python/tf/Tensor#ref + # experimental_ref is being deprecated for ref + tensor = tensor.ref() + elif hasattr(tensor, "experimental_ref"): + # tensor.experimental_ref is an experimental API + # and can be changed or removed. + # Ref: https://www.tensorflow.org/api_docs/python/tf/Tensor#experimental_ref + tensor = tensor.experimental_ref() + else: + raise Exception( + "Neither ref nor experimental_ref API present. Check TF version" + ) if not current_coll.has_tensor(tensor): # tensor will be added to this coll below colls_with_tensor.add(current_coll) From 3e047d9d41d5273e51251f8ace10c33e2f634ff3 Mon Sep 17 00:00:00 2001 From: NihalHarish Date: Mon, 21 Sep 2020 19:01:30 -0700 Subject: [PATCH 2/2] retrigger CI