tf.keras.tree.assert_same_paths

Asserts that two structures have identical paths in their tree structure.

This function verifies that two nested structures have the same paths. Unlike assert_same_structure, this function only checks the paths and ignores the collection types. For Sequences, to path is the index: 0, 1, 2, etc. For Mappings, the path is the key, for instance "a", "b", "c". Note that namedtuples also use indices and not field names for the path.

Examples:

keras.tree.assert_same_paths([0, 1], (2, 3))
Point1 = collections.namedtuple('Point1', ['x', 'y'])
Point2 = collections.namedtuple('Point2', ['x', 'y'])
keras.tree.assert_same_paths(Point1(0, 1), Point2(2, 3))

a an arbitrarily nested structure.
b an arbitrarily nested structure.

ValueError If the paths in structure a don't match the paths in structure b. The error message will include the specific paths that differ.