tf.keras.tree.assert_same_paths
Stay organized with collections
Save and categorize content based on your preferences.
Asserts that two structures have identical paths in their tree structure.
tf.keras.tree.assert_same_paths(
a, b
)
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))
Args |
a
|
an arbitrarily nested structure.
|
b
|
an arbitrarily nested structure.
|
Raises |
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.
|
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates. Some content is licensed under the numpy license.
Last updated 2026-10-31 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2026-10-31 UTC."],[],[]]