|View source on GitHub|
func to each entry in
structure and returns a new structure.
tf.nest.map_structure( func, *structure, **kwargs )
func(x, x, ...) where x[i] is an entry in
structure[i]. All structures in
structure must have the same arity,
and the return value will contain results with the same structure layout.
func: A callable that accepts as many arguments as there are structures.
*structure: scalar, or tuple or list of constructed scalars and/or other tuples/lists, or scalars. Note: numpy arrays are considered as scalars.
**kwargs: Valid keyword args are:
check_types: If set to
True(default) the types of iterables within the structures have to be same (e.g.
map_structure(func, , (1,))raises a
TypeErrorexception). To allow this set this argument to
False. Note that namedtuples with identical name and fields are always considered to have the same shallow structure.
expand_composites: If set to
True, then composite tensors such as
tf.RaggedTensorare expanded into their component tensors. If
False(the default), then composite tensors are not expanded.
A new structure with the same arity as
structure, whose values correspond
func(x, x, ...) where
x[i] is a value in the corresponding
structure[i]. If there are different sequence types and
False the sequence types of the first structure will be
funcis not callable or if the structures do not match each other by depth tree.
ValueError: If no structure is provided or if the structures do not match each other by type.
ValueError: If wrong keyword arguments are provided.