tf.contrib.framework.nest.yield_flat_paths
Stay organized with collections
Save and categorize content based on your preferences.
Yields paths for some nested structure.
tf.contrib.framework.nest.yield_flat_paths(
nest, expand_composites=False
)
Paths are lists of objects which can be str-converted, which may include
integers or other types which are used as indices in a dict.
The flat list will be in the corresponding order as if you called
snt.nest.flatten
on the structure. This is handy for naming Tensors such
the TF scope structure matches the tuple structure.
E.g. if we have a tuple value = Foo(a=3, b=Bar(c=23, d=42))
>>> nest.flatten(value)
[3, 23, 42]
>>> list(nest.yield_flat_paths(value))
[('a',), ('b', 'c'), ('b', 'd')]
>>> list(nest.yield_flat_paths({'a': [3]}))
[('a', 0)]
>>> list(nest.yield_flat_paths({'a': 3}))
[('a',)]
Args |
nest
|
the value to produce a flattened paths list for.
|
expand_composites
|
If true, then composite tensors such as tf.SparseTensor
and tf.RaggedTensor are expanded into their component tensors.
|
Yields:
Tuples containing index or key values which form the path to a specific
leaf value in the nested structure.
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 2020-10-01 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 2020-10-01 UTC."],[],[],null,["# tf.contrib.framework.nest.yield_flat_paths\n\n\u003cbr /\u003e\n\n|---------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v1.15.0/tensorflow/python/util/nest.py#L1240-L1277) |\n\nYields paths for some nested structure. \n\n tf.contrib.framework.nest.yield_flat_paths(\n nest, expand_composites=False\n )\n\nPaths are lists of objects which can be str-converted, which may include\nintegers or other types which are used as indices in a dict.\n\nThe flat list will be in the corresponding order as if you called\n`snt.nest.flatten` on the structure. This is handy for naming Tensors such\nthe TF scope structure matches the tuple structure.\n\nE.g. if we have a tuple `value = Foo(a=3, b=Bar(c=23, d=42))` \n\n \u003e\u003e\u003e nest.flatten(value)\n [3, 23, 42]\n \u003e\u003e\u003e list(nest.yield_flat_paths(value))\n [('a',), ('b', 'c'), ('b', 'd')]\n\n \u003e\u003e\u003e list(nest.yield_flat_paths({'a': [3]}))\n [('a', 0)]\n \u003e\u003e\u003e list(nest.yield_flat_paths({'a': 3}))\n [('a',)]\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|---------------------|------------------------------------------------------------------------------------------------------------------------|\n| `nest` | the value to produce a flattened paths list for. |\n| `expand_composites` | If true, then composite tensors such as tf.SparseTensor and tf.RaggedTensor are expanded into their component tensors. |\n\n\u003cbr /\u003e\n\n#### Yields:\n\nTuples containing index or key values which form the path to a specific\nleaf value in the nested structure."]]