Module: tff.structure
Stay organized with collections
Save and categorize content based on your preferences.
Container for structures with named and/or unnamed fields.
Classes
class Callable
class Iterable
class Iterator
class Mapping
class Struct
: Represents a struct-like structure with named and/or unnamed fields.
Functions
flatten(...)
: Returns a list of values in a possibly recursively nested Struct
.
from_container(...)
: Creates an instance of Struct
from a Python container.
has_field(...)
: Returns True
if the structure
has the field
.
is_same_structure(...)
: Compares whether a
and b
have the same nested structure.
iter_elements(...)
: Returns an iterator over (name, value) pairs from a Struct
.
map_structure(...)
: Applies fn
to each entry in structure
and returns a new structure.
name_list(...)
: Returns a list
of the names of the named fields in struct
.
name_list_with_nones(...)
: Returns an iterator over the names of all fields in struct
.
name_to_index_map(...)
: Returns map from names in structure
to their indices.
pack_sequence_as(...)
: Returns a list of values in a possibly recursively nested Struct
.
to_elements(...)
: Retrieves the list of (name, value) pairs from a Struct
.
to_odict(...)
: Returns struct
as an collections.OrderedDict
, if possible.
to_odict_or_tuple(...)
: Returns struct
as an collections.OrderedDict
or tuple
, if possible.
update_struct(...)
: Constructs a new structure
with new values for fields in kwargs
.
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 2024-09-20 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 2024-09-20 UTC."],[],[],null,["# Module: tff.structure\n\n\u003cbr /\u003e\n\n|-------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/federated/blob/v0.87.0 Version 2.0, January 2004 Licensed under the Apache License, Version 2.0 (the) |\n\nContainer for structures with named and/or unnamed fields.\n\nClasses\n-------\n\n[`class Callable`](../tff/structure/Callable)\n\n[`class Iterable`](../tff/structure/Iterable)\n\n[`class Iterator`](../tff/structure/Iterator)\n\n[`class Mapping`](../tff/structure/Mapping)\n\n[`class Struct`](../tff/structure/Struct): Represents a struct-like structure with named and/or unnamed fields.\n\nFunctions\n---------\n\n[`flatten(...)`](../tff/structure/flatten): Returns a list of values in a possibly recursively nested `Struct`.\n\n[`from_container(...)`](../tff/structure/from_container): Creates an instance of `Struct` from a Python container.\n\n[`has_field(...)`](../tff/structure/has_field): Returns `True` if the `structure` has the `field`.\n\n[`is_same_structure(...)`](../tff/structure/is_same_structure): Compares whether `a` and `b` have the same nested structure.\n\n[`iter_elements(...)`](../tff/structure/iter_elements): Returns an iterator over (name, value) pairs from a `Struct`.\n\n[`map_structure(...)`](../tff/structure/map_structure): Applies `fn` to each entry in `structure` and returns a new structure.\n\n[`name_list(...)`](../tff/structure/name_list): Returns a `list` of the names of the named fields in `struct`.\n\n[`name_list_with_nones(...)`](../tff/structure/name_list_with_nones): Returns an iterator over the names of all fields in `struct`.\n\n[`name_to_index_map(...)`](../tff/structure/name_to_index_map): Returns map from names in `structure` to their indices.\n\n[`pack_sequence_as(...)`](../tff/structure/pack_sequence_as): Returns a list of values in a possibly recursively nested `Struct`.\n\n[`to_elements(...)`](../tff/structure/to_elements): Retrieves the list of (name, value) pairs from a `Struct`.\n\n[`to_odict(...)`](../tff/structure/to_odict): Returns `struct` as an `collections.OrderedDict`, if possible.\n\n[`to_odict_or_tuple(...)`](../tff/structure/to_odict_or_tuple): Returns `struct` as an `collections.OrderedDict` or `tuple`, if possible.\n\n[`update_struct(...)`](../tff/structure/update_struct): Constructs a new `structure` with new values for fields in `kwargs`."]]