tf_agents.utils.nest_utils.assert_same_structure
Stay organized with collections
Save and categorize content based on your preferences.
Same as tf.nest.assert_same_structure but with cleaner error messages.
tf_agents.utils.nest_utils.assert_same_structure(
nest1,
nest2,
check_types: bool = True,
expand_composites: bool = False,
allow_shallow_nest1: bool = False,
message: Optional[Text] = None
) -> None
Args |
nest1
|
an arbitrarily nested structure.
|
nest2
|
an arbitrarily nested structure.
|
check_types
|
if True (default) types of sequences are checked as well,
including the keys of dictionaries. If set to False , for example a list
and a tuple of objects will look the same if they have the same size. Note
that namedtuples with identical name and fields are always considered to
have the same shallow structure. Two types will also be considered the
same if they are both list subtypes (which allows "list" and
"_ListWrapper" from trackable dependency tracking to compare equal).
|
expand_composites
|
If true, then composite tensors such as tf.SparseTensor
and tf.RaggedTensor are expanded into their component tensors.
|
allow_shallow_nest1
|
If True , nest1 is allowed to be more shallow than
nest2 .
|
message
|
Optional error message to provide in case of failure.
|
Raises |
ValueError
|
If the two structures do not have the same number of elements
or if the two structures are not nested in the same way.
|
TypeError
|
If the two structures differ in the type of sequence in any
of their substructures. Only possible if check_types is True .
|
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.
Last updated 2024-04-26 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 2024-04-26 UTC."],[],[]]