|TensorFlow 1 version||View source on GitHub|
Returns a given flattened sequence packed into a given structure.
Compat aliases for migration
See Migration guide for more details.
tf.nest.pack_sequence_as( structure, flat_sequence, expand_composites=False )
Used in the notebooks
|Used in the tutorials|
structure is a scalar,
flat_sequence must be a single-element list;
in this case the return value is
structure is or contains a dict instance, the keys will be sorted to
pack the flat sequence in deterministic order. This is true also for
OrderedDict instances: their sequence order is ignored, the sorting order of
keys is used instead. The same convention is followed in
This correctly repacks dicts and
OrderedDicts after they have been
flattened, and also allows flattening an
OrderedDict and then repacking it
back using a corresponding plain dict, or vice-versa.
Dictionaries with non-sortable keys cannot be flattened.