View source on GitHub
|
Flattens a possibly nested structure into a list.
tf.keras.tree.flatten_with_path(
structure
)
This is a variant of flattens() which produces a
list of pairs: (path, item). A path is a tuple of indices and/or keys
which uniquely identifies the position of the corresponding item.
Dictionaries with non-sortable keys are not supported.
Examples:
keras.flatten_with_path([{"foo": 42}])[((0, 'foo'), 42)]
Args | |
|---|---|
structure
|
An arbitrarily nested structure. |
Returns | |
|---|---|
A list of (path, item) pairs corresponding to the flattened
version of the input structure.
|
View source on GitHub