|
44 | 44 | from tensorflow.python.platform import test |
45 | 45 | from tensorflow.python.training.tracking import util as trackable_util |
46 | 46 | from tensorflow.python.util import nest |
47 | | -from tensorflow.python.util import object_identity |
48 | 47 |
|
49 | 48 |
|
50 | 49 | class _RNNCellWithConstants(keras.layers.Layer): |
@@ -130,10 +129,11 @@ def test_timedistributed_dense(self): |
130 | 129 |
|
131 | 130 | # check whether the model variables are present in the |
132 | 131 | # trackable list of objects |
133 | | - checkpointed_objects = object_identity.ObjectIdentitySet( |
134 | | - trackable_util.list_objects(model)) |
| 132 | + checkpointed_object_ids = { |
| 133 | + id(o) for o in trackable_util.list_objects(model) |
| 134 | + } |
135 | 135 | for v in model.variables: |
136 | | - self.assertIn(v, checkpointed_objects) |
| 136 | + self.assertIn(id(v), checkpointed_object_ids) |
137 | 137 |
|
138 | 138 | def test_timedistributed_static_batch_size(self): |
139 | 139 | model = keras.models.Sequential() |
@@ -492,10 +492,11 @@ def test_bidirectional(self, mode): |
492 | 492 |
|
493 | 493 | # check whether the model variables are present in the |
494 | 494 | # trackable list of objects |
495 | | - checkpointed_objects = object_identity.ObjectIdentitySet( |
496 | | - trackable_util.list_objects(model)) |
| 495 | + checkpointed_object_ids = { |
| 496 | + id(o) for o in trackable_util.list_objects(model) |
| 497 | + } |
497 | 498 | for v in model.variables: |
498 | | - self.assertIn(v, checkpointed_objects) |
| 499 | + self.assertIn(id(v), checkpointed_object_ids) |
499 | 500 |
|
500 | 501 | # test compute output shape |
501 | 502 | ref_shape = model.layers[-1].output.shape |
@@ -1030,10 +1031,11 @@ def test_custom_backward_layer(self, mode): |
1030 | 1031 |
|
1031 | 1032 | # check whether the model variables are present in the |
1032 | 1033 | # trackable list of objects |
1033 | | - checkpointed_objects = object_identity.ObjectIdentitySet( |
1034 | | - trackable_util.list_objects(model)) |
| 1034 | + checkpointed_object_ids = { |
| 1035 | + id(o) for o in trackable_util.list_objects(model) |
| 1036 | + } |
1035 | 1037 | for v in model.variables: |
1036 | | - self.assertIn(v, checkpointed_objects) |
| 1038 | + self.assertIn(id(v), checkpointed_object_ids) |
1037 | 1039 |
|
1038 | 1040 | # test compute output shape |
1039 | 1041 | ref_shape = model.layers[-1].output.shape |
|
0 commit comments