tf.nest.assert_same_structure

View source on GitHub

Asserts that two structures are nested in the same way.

tf.nest.assert_same_structure(
    nest1, nest2, check_types=True, expand_composites=False
)

Note that namedtuples with identical name and fields are always considered to have the same shallow structure (even with check_types=True). For instance, this code will print True:

def nt(a, b):
  return collections.namedtuple('foo', 'a b')(a, b)
print(assert_same_structure(nt(0, 1), nt(2, 3)))

Args:

Raises: