diff --git a/tensorflow_probability/python/layers/internal/distribution_tensor_coercible_test.py b/tensorflow_probability/python/layers/internal/distribution_tensor_coercible_test.py index feed13fb68..68932e5f95 100644 --- a/tensorflow_probability/python/layers/internal/distribution_tensor_coercible_test.py +++ b/tensorflow_probability/python/layers/internal/distribution_tensor_coercible_test.py @@ -305,10 +305,14 @@ def testTypeObjectLeakage(self): # These weakrefs could potentially come from tf.function.variables. dist = layer(x) gc.collect() + gc.collect() + gc.collect() before_objs = len(gc.get_objects()) for _ in range(int(1e2)): dist = layer(x) gc.collect() + gc.collect() + gc.collect() after_objs = len(gc.get_objects()) del dist