tf.contrib.framework.nest.assert_shallow_structure
Asserts that shallow_tree is a shallow structure of input_tree.
tf.contrib.framework.nest.assert_shallow_structure(
    shallow_tree, input_tree, check_types=True, expand_composites=False,
    check_subtrees_length=True
)
  That is, this function tests if the input_tree structure can be created from the shallow_tree structure by replacing its leaf nodes with deeper tree structures.
Examples:
The following code will raise an exception:
shallow_tree = {"a": "A", "b": "B"}
input_tree = {"a": 1, "c": 2}
assert_shallow_structure(shallow_tree, input_tree)
 The following code will raise an exception:
shallow_tree = ["a", "b"] input_tree = ["c", ["d", "e"], "f"] assert_shallow_structure(shallow_tree, input_tree)
The following code will not raise an exception:
shallow_tree = ["a", "b"] input_tree = ["c", ["d", "e"], "f"] assert_shallow_structure(shallow_tree, input_tree, check_subtrees_length=False)
| Args | |
|---|---|
| shallow_tree | an arbitrarily nested structure. | 
| input_tree | an arbitrarily nested structure. | 
| check_types | if True(default) the sequence types ofshallow_treeandinput_treehave to be the same. Note that even with check_types==True, this function will consider two different namedtuple classes with the same name and _fields attribute to be the same class. | 
| expand_composites | If true, then composite tensors such as tf.SparseTensor and tf.RaggedTensor are expanded into their component tensors. | 
| check_subtrees_length | if True(default) the subtreesshallow_treeandinput_treehave to be the same length. IfFalsesequences are treated as key-value like mappings allowing them to be considered as valid subtrees. Note that this may drop parts of theinput_tree. | 
| Raises | |
|---|---|
| TypeError | If shallow_treeis a sequence butinput_treeis not. | 
| TypeError | If the sequence types of shallow_treeare different frominput_tree. Only raised ifcheck_typesisTrue. | 
| ValueError | If the sequence lengths of shallow_treeare different frominput_tree. | 
    © 2020 The TensorFlow Authors. All rights reserved.
Licensed under the Creative Commons Attribution License 3.0.
Code samples licensed under the Apache 2.0 License.
    https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/contrib/framework/nest/assert_shallow_structure