Assert that both structures are equivalent. This function is more strict than tf.nest.assert_same_structure since it also requires that Tensors have the same dtype and shape. Args: nest1: A nested structure. nest2: A nested structure.
(nest1, nest2)
| 135 | |
| 136 | |
| 137 | def assert_same(nest1, nest2): |
| 138 | """Assert that both structures are equivalent. |
| 139 | |
| 140 | This function is more strict than tf.nest.assert_same_structure since it also |
| 141 | requires that Tensors have the same dtype and shape. |
| 142 | |
| 143 | Args: |
| 144 | nest1: A nested structure. |
| 145 | nest2: A nested structure. |
| 146 | """ |
| 147 | tf.nest.assert_same_structure(nest1, nest2) |
| 148 | for t1, t2 in zip(tf.nest.flatten(nest1), tf.nest.flatten(nest2)): |
| 149 | assert t1.dtype == t2.dtype |
| 150 | if isinstance(t1, tf.Tensor) and isinstance(t2, tf.Tensor): |
| 151 | assert t1.shape == t2.shape |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…