Constructs a structure from a type_spec
tree of tff.TensorType
s.
tff.types.structure_from_tensor_type_tree(
fn: Callable[[tff.types.TensorType
], object],
type_spec
) -> object
Args |
fn
|
A callable used to generate the elements with which to fill the
resulting structure. fn will be called exactly once per leaf
tff.TensorType in the order they appear in the type_spec structure.
|
type_spec
|
A TFF type or value convertible to TFF type. Once converted,
type_spec must be a tff.TensorType or tff.StructType containing only
other tff.TensorType s and tff.StructType s.
|
Returns |
A structure with the same shape and Python containers as type_spec but
with the tff.TensorType elements replaced with the results of fn .
|
Raises |
ValueError
|
if the provided type_spec is not a structural or tensor type.
|