Asserts that two structures are nested in the same way.
tf.keras.tree.assert_same_structure(
a, b, check_types=True
)
Note that namedtuples with identical name and fields will not be considered
as same structures even check_types=False
.
Examples:
keras.tree.assert_same_structure([(0, 1)], [(2, 3)])
Foo = collections.namedtuple('Foo', ['a', 'b'])
AlsoFoo = collections.namedtuple('Foo', ['a', 'b'])
keras.tree.assert_same_structure(Foo(0, 1), Foo(2, 3))
keras.tree.assert_same_structure(Foo(0, 1), AlsoFoo(2, 3))
Traceback (most recent call last):
ValueError: `a` and `b` don't have the same structure.