LostTech.TensorFlow : API Documentation

Type tf.nest

Namespace tensorflow

Public static methods

void assert_same_structure(PythonFunctionContainer nest1, object nest2, string check_types, ImplicitContainer<T> expand_composites)

Asserts that two structures are nested in the same way.

Note that namedtuples with identical name and fields are always considered to have the same shallow structure (even with `check_types=True`). For instance, this code will print `True`:
Parameters
PythonFunctionContainer nest1
an arbitrarily nested structure.
object nest2
an arbitrarily nested structure.
string check_types
if `True` (default) types of sequences are checked as well, including the keys of dictionaries. If set to `False`, for example a list and a tuple of objects will look the same if they have the same size. Note that namedtuples with identical name and fields are always considered to have the same shallow structure. Two types will also be considered the same if they are both list subtypes (which allows "list" and "_ListWrapper" from trackable dependency tracking to compare equal).
ImplicitContainer<T> expand_composites
If true, then composite tensors such as tf.SparseTensor and tf.RaggedTensor are expanded into their component tensors.
Show Example
def nt(a, b):
              return collections.namedtuple('foo', 'a b')(a, b)
            print(assert_same_structure(nt(0, 1), nt(2, 3))) 

void assert_same_structure(PythonFunctionContainer nest1, object nest2, bool check_types, ImplicitContainer<T> expand_composites)

Asserts that two structures are nested in the same way.

Note that namedtuples with identical name and fields are always considered to have the same shallow structure (even with `check_types=True`). For instance, this code will print `True`:
Parameters
PythonFunctionContainer nest1
an arbitrarily nested structure.
object nest2
an arbitrarily nested structure.
bool check_types
if `True` (default) types of sequences are checked as well, including the keys of dictionaries. If set to `False`, for example a list and a tuple of objects will look the same if they have the same size. Note that namedtuples with identical name and fields are always considered to have the same shallow structure. Two types will also be considered the same if they are both list subtypes (which allows "list" and "_ListWrapper" from trackable dependency tracking to compare equal).
ImplicitContainer<T> expand_composites
If true, then composite tensors such as tf.SparseTensor and tf.RaggedTensor are expanded into their component tensors.
Show Example
def nt(a, b):
              return collections.namedtuple('foo', 'a b')(a, b)
            print(assert_same_structure(nt(0, 1), nt(2, 3))) 

void assert_same_structure(IEnumerable<IGraphNodeBase> nest1, object nest2, string check_types, ImplicitContainer<T> expand_composites)

Asserts that two structures are nested in the same way.

Note that namedtuples with identical name and fields are always considered to have the same shallow structure (even with `check_types=True`). For instance, this code will print `True`:
Parameters
IEnumerable<IGraphNodeBase> nest1
an arbitrarily nested structure.
object nest2
an arbitrarily nested structure.
string check_types
if `True` (default) types of sequences are checked as well, including the keys of dictionaries. If set to `False`, for example a list and a tuple of objects will look the same if they have the same size. Note that namedtuples with identical name and fields are always considered to have the same shallow structure. Two types will also be considered the same if they are both list subtypes (which allows "list" and "_ListWrapper" from trackable dependency tracking to compare equal).
ImplicitContainer<T> expand_composites
If true, then composite tensors such as tf.SparseTensor and tf.RaggedTensor are expanded into their component tensors.
Show Example
def nt(a, b):
              return collections.namedtuple('foo', 'a b')(a, b)
            print(assert_same_structure(nt(0, 1), nt(2, 3))) 

void assert_same_structure(PythonFunctionContainer nest1, IEnumerable<IGraphNodeBase> nest2, bool check_types, ImplicitContainer<T> expand_composites)

Asserts that two structures are nested in the same way.

Note that namedtuples with identical name and fields are always considered to have the same shallow structure (even with `check_types=True`). For instance, this code will print `True`:
Parameters
PythonFunctionContainer nest1
an arbitrarily nested structure.
IEnumerable<IGraphNodeBase> nest2
an arbitrarily nested structure.
bool check_types
if `True` (default) types of sequences are checked as well, including the keys of dictionaries. If set to `False`, for example a list and a tuple of objects will look the same if they have the same size. Note that namedtuples with identical name and fields are always considered to have the same shallow structure. Two types will also be considered the same if they are both list subtypes (which allows "list" and "_ListWrapper" from trackable dependency tracking to compare equal).
ImplicitContainer<T> expand_composites
If true, then composite tensors such as tf.SparseTensor and tf.RaggedTensor are expanded into their component tensors.
Show Example
def nt(a, b):
              return collections.namedtuple('foo', 'a b')(a, b)
            print(assert_same_structure(nt(0, 1), nt(2, 3))) 

void assert_same_structure(PythonFunctionContainer nest1, IEnumerable<IGraphNodeBase> nest2, string check_types, ImplicitContainer<T> expand_composites)

Asserts that two structures are nested in the same way.

Note that namedtuples with identical name and fields are always considered to have the same shallow structure (even with `check_types=True`). For instance, this code will print `True`:
Parameters
PythonFunctionContainer nest1
an arbitrarily nested structure.
IEnumerable<IGraphNodeBase> nest2
an arbitrarily nested structure.
string check_types
if `True` (default) types of sequences are checked as well, including the keys of dictionaries. If set to `False`, for example a list and a tuple of objects will look the same if they have the same size. Note that namedtuples with identical name and fields are always considered to have the same shallow structure. Two types will also be considered the same if they are both list subtypes (which allows "list" and "_ListWrapper" from trackable dependency tracking to compare equal).
ImplicitContainer<T> expand_composites
If true, then composite tensors such as tf.SparseTensor and tf.RaggedTensor are expanded into their component tensors.
Show Example
def nt(a, b):
              return collections.namedtuple('foo', 'a b')(a, b)
            print(assert_same_structure(nt(0, 1), nt(2, 3))) 

void assert_same_structure(PythonFunctionContainer nest1, PythonFunctionContainer nest2, bool check_types, ImplicitContainer<T> expand_composites)

Asserts that two structures are nested in the same way.

Note that namedtuples with identical name and fields are always considered to have the same shallow structure (even with `check_types=True`). For instance, this code will print `True`:
Parameters
PythonFunctionContainer nest1
an arbitrarily nested structure.
PythonFunctionContainer nest2
an arbitrarily nested structure.
bool check_types
if `True` (default) types of sequences are checked as well, including the keys of dictionaries. If set to `False`, for example a list and a tuple of objects will look the same if they have the same size. Note that namedtuples with identical name and fields are always considered to have the same shallow structure. Two types will also be considered the same if they are both list subtypes (which allows "list" and "_ListWrapper" from trackable dependency tracking to compare equal).
ImplicitContainer<T> expand_composites
If true, then composite tensors such as tf.SparseTensor and tf.RaggedTensor are expanded into their component tensors.
Show Example
def nt(a, b):
              return collections.namedtuple('foo', 'a b')(a, b)
            print(assert_same_structure(nt(0, 1), nt(2, 3))) 

void assert_same_structure(IEnumerable<IGraphNodeBase> nest1, PythonFunctionContainer nest2, bool check_types, ImplicitContainer<T> expand_composites)

Asserts that two structures are nested in the same way.

Note that namedtuples with identical name and fields are always considered to have the same shallow structure (even with `check_types=True`). For instance, this code will print `True`:
Parameters
IEnumerable<IGraphNodeBase> nest1
an arbitrarily nested structure.
PythonFunctionContainer nest2
an arbitrarily nested structure.
bool check_types
if `True` (default) types of sequences are checked as well, including the keys of dictionaries. If set to `False`, for example a list and a tuple of objects will look the same if they have the same size. Note that namedtuples with identical name and fields are always considered to have the same shallow structure. Two types will also be considered the same if they are both list subtypes (which allows "list" and "_ListWrapper" from trackable dependency tracking to compare equal).
ImplicitContainer<T> expand_composites
If true, then composite tensors such as tf.SparseTensor and tf.RaggedTensor are expanded into their component tensors.
Show Example
def nt(a, b):
              return collections.namedtuple('foo', 'a b')(a, b)
            print(assert_same_structure(nt(0, 1), nt(2, 3))) 

void assert_same_structure(object nest1, object nest2, string check_types, ImplicitContainer<T> expand_composites)

Asserts that two structures are nested in the same way.

Note that namedtuples with identical name and fields are always considered to have the same shallow structure (even with `check_types=True`). For instance, this code will print `True`:
Parameters
object nest1
an arbitrarily nested structure.
object nest2
an arbitrarily nested structure.
string check_types
if `True` (default) types of sequences are checked as well, including the keys of dictionaries. If set to `False`, for example a list and a tuple of objects will look the same if they have the same size. Note that namedtuples with identical name and fields are always considered to have the same shallow structure. Two types will also be considered the same if they are both list subtypes (which allows "list" and "_ListWrapper" from trackable dependency tracking to compare equal).
ImplicitContainer<T> expand_composites
If true, then composite tensors such as tf.SparseTensor and tf.RaggedTensor are expanded into their component tensors.
Show Example
def nt(a, b):
              return collections.namedtuple('foo', 'a b')(a, b)
            print(assert_same_structure(nt(0, 1), nt(2, 3))) 

void assert_same_structure(object nest1, object nest2, bool check_types, ImplicitContainer<T> expand_composites)

Asserts that two structures are nested in the same way.

Note that namedtuples with identical name and fields are always considered to have the same shallow structure (even with `check_types=True`). For instance, this code will print `True`:
Parameters
object nest1
an arbitrarily nested structure.
object nest2
an arbitrarily nested structure.
bool check_types
if `True` (default) types of sequences are checked as well, including the keys of dictionaries. If set to `False`, for example a list and a tuple of objects will look the same if they have the same size. Note that namedtuples with identical name and fields are always considered to have the same shallow structure. Two types will also be considered the same if they are both list subtypes (which allows "list" and "_ListWrapper" from trackable dependency tracking to compare equal).
ImplicitContainer<T> expand_composites
If true, then composite tensors such as tf.SparseTensor and tf.RaggedTensor are expanded into their component tensors.
Show Example
def nt(a, b):
              return collections.namedtuple('foo', 'a b')(a, b)
            print(assert_same_structure(nt(0, 1), nt(2, 3))) 

void assert_same_structure(object nest1, PythonFunctionContainer nest2, string check_types, ImplicitContainer<T> expand_composites)

Asserts that two structures are nested in the same way.

Note that namedtuples with identical name and fields are always considered to have the same shallow structure (even with `check_types=True`). For instance, this code will print `True`:
Parameters
object nest1
an arbitrarily nested structure.
PythonFunctionContainer nest2
an arbitrarily nested structure.
string check_types
if `True` (default) types of sequences are checked as well, including the keys of dictionaries. If set to `False`, for example a list and a tuple of objects will look the same if they have the same size. Note that namedtuples with identical name and fields are always considered to have the same shallow structure. Two types will also be considered the same if they are both list subtypes (which allows "list" and "_ListWrapper" from trackable dependency tracking to compare equal).
ImplicitContainer<T> expand_composites
If true, then composite tensors such as tf.SparseTensor and tf.RaggedTensor are expanded into their component tensors.
Show Example
def nt(a, b):
              return collections.namedtuple('foo', 'a b')(a, b)
            print(assert_same_structure(nt(0, 1), nt(2, 3))) 

void assert_same_structure(object nest1, PythonFunctionContainer nest2, bool check_types, ImplicitContainer<T> expand_composites)

Asserts that two structures are nested in the same way.

Note that namedtuples with identical name and fields are always considered to have the same shallow structure (even with `check_types=True`). For instance, this code will print `True`:
Parameters
object nest1
an arbitrarily nested structure.
PythonFunctionContainer nest2
an arbitrarily nested structure.
bool check_types
if `True` (default) types of sequences are checked as well, including the keys of dictionaries. If set to `False`, for example a list and a tuple of objects will look the same if they have the same size. Note that namedtuples with identical name and fields are always considered to have the same shallow structure. Two types will also be considered the same if they are both list subtypes (which allows "list" and "_ListWrapper" from trackable dependency tracking to compare equal).
ImplicitContainer<T> expand_composites
If true, then composite tensors such as tf.SparseTensor and tf.RaggedTensor are expanded into their component tensors.
Show Example
def nt(a, b):
              return collections.namedtuple('foo', 'a b')(a, b)
            print(assert_same_structure(nt(0, 1), nt(2, 3))) 

void assert_same_structure(IEnumerable<IGraphNodeBase> nest1, object nest2, bool check_types, ImplicitContainer<T> expand_composites)

Asserts that two structures are nested in the same way.

Note that namedtuples with identical name and fields are always considered to have the same shallow structure (even with `check_types=True`). For instance, this code will print `True`:
Parameters
IEnumerable<IGraphNodeBase> nest1
an arbitrarily nested structure.
object nest2
an arbitrarily nested structure.
bool check_types
if `True` (default) types of sequences are checked as well, including the keys of dictionaries. If set to `False`, for example a list and a tuple of objects will look the same if they have the same size. Note that namedtuples with identical name and fields are always considered to have the same shallow structure. Two types will also be considered the same if they are both list subtypes (which allows "list" and "_ListWrapper" from trackable dependency tracking to compare equal).
ImplicitContainer<T> expand_composites
If true, then composite tensors such as tf.SparseTensor and tf.RaggedTensor are expanded into their component tensors.
Show Example
def nt(a, b):
              return collections.namedtuple('foo', 'a b')(a, b)
            print(assert_same_structure(nt(0, 1), nt(2, 3))) 

void assert_same_structure(object nest1, IEnumerable<object> nest2, string check_types, ImplicitContainer<T> expand_composites)

Asserts that two structures are nested in the same way.

Note that namedtuples with identical name and fields are always considered to have the same shallow structure (even with `check_types=True`). For instance, this code will print `True`:
Parameters
object nest1
an arbitrarily nested structure.
IEnumerable<object> nest2
an arbitrarily nested structure.
string check_types
if `True` (default) types of sequences are checked as well, including the keys of dictionaries. If set to `False`, for example a list and a tuple of objects will look the same if they have the same size. Note that namedtuples with identical name and fields are always considered to have the same shallow structure. Two types will also be considered the same if they are both list subtypes (which allows "list" and "_ListWrapper" from trackable dependency tracking to compare equal).
ImplicitContainer<T> expand_composites
If true, then composite tensors such as tf.SparseTensor and tf.RaggedTensor are expanded into their component tensors.
Show Example
def nt(a, b):
              return collections.namedtuple('foo', 'a b')(a, b)
            print(assert_same_structure(nt(0, 1), nt(2, 3))) 

void assert_same_structure(IEnumerable<IGraphNodeBase> nest1, IEnumerable<IGraphNodeBase> nest2, bool check_types, ImplicitContainer<T> expand_composites)

Asserts that two structures are nested in the same way.

Note that namedtuples with identical name and fields are always considered to have the same shallow structure (even with `check_types=True`). For instance, this code will print `True`:
Parameters
IEnumerable<IGraphNodeBase> nest1
an arbitrarily nested structure.
IEnumerable<IGraphNodeBase> nest2
an arbitrarily nested structure.
bool check_types
if `True` (default) types of sequences are checked as well, including the keys of dictionaries. If set to `False`, for example a list and a tuple of objects will look the same if they have the same size. Note that namedtuples with identical name and fields are always considered to have the same shallow structure. Two types will also be considered the same if they are both list subtypes (which allows "list" and "_ListWrapper" from trackable dependency tracking to compare equal).
ImplicitContainer<T> expand_composites
If true, then composite tensors such as tf.SparseTensor and tf.RaggedTensor are expanded into their component tensors.
Show Example
def nt(a, b):
              return collections.namedtuple('foo', 'a b')(a, b)
            print(assert_same_structure(nt(0, 1), nt(2, 3))) 

void assert_same_structure(object nest1, IEnumerable<object> nest2, bool check_types, ImplicitContainer<T> expand_composites)

Asserts that two structures are nested in the same way.

Note that namedtuples with identical name and fields are always considered to have the same shallow structure (even with `check_types=True`). For instance, this code will print `True`:
Parameters
object nest1
an arbitrarily nested structure.
IEnumerable<object> nest2
an arbitrarily nested structure.
bool check_types
if `True` (default) types of sequences are checked as well, including the keys of dictionaries. If set to `False`, for example a list and a tuple of objects will look the same if they have the same size. Note that namedtuples with identical name and fields are always considered to have the same shallow structure. Two types will also be considered the same if they are both list subtypes (which allows "list" and "_ListWrapper" from trackable dependency tracking to compare equal).
ImplicitContainer<T> expand_composites
If true, then composite tensors such as tf.SparseTensor and tf.RaggedTensor are expanded into their component tensors.
Show Example
def nt(a, b):
              return collections.namedtuple('foo', 'a b')(a, b)
            print(assert_same_structure(nt(0, 1), nt(2, 3))) 

void assert_same_structure(PythonFunctionContainer nest1, PythonFunctionContainer nest2, string check_types, ImplicitContainer<T> expand_composites)

Asserts that two structures are nested in the same way.

Note that namedtuples with identical name and fields are always considered to have the same shallow structure (even with `check_types=True`). For instance, this code will print `True`:
Parameters
PythonFunctionContainer nest1
an arbitrarily nested structure.
PythonFunctionContainer nest2
an arbitrarily nested structure.
string check_types
if `True` (default) types of sequences are checked as well, including the keys of dictionaries. If set to `False`, for example a list and a tuple of objects will look the same if they have the same size. Note that namedtuples with identical name and fields are always considered to have the same shallow structure. Two types will also be considered the same if they are both list subtypes (which allows "list" and "_ListWrapper" from trackable dependency tracking to compare equal).
ImplicitContainer<T> expand_composites
If true, then composite tensors such as tf.SparseTensor and tf.RaggedTensor are expanded into their component tensors.
Show Example
def nt(a, b):
              return collections.namedtuple('foo', 'a b')(a, b)
            print(assert_same_structure(nt(0, 1), nt(2, 3))) 

void assert_same_structure(IEnumerable<IGraphNodeBase> nest1, IEnumerable<IGraphNodeBase> nest2, string check_types, ImplicitContainer<T> expand_composites)

Asserts that two structures are nested in the same way.

Note that namedtuples with identical name and fields are always considered to have the same shallow structure (even with `check_types=True`). For instance, this code will print `True`:
Parameters
IEnumerable<IGraphNodeBase> nest1
an arbitrarily nested structure.
IEnumerable<IGraphNodeBase> nest2
an arbitrarily nested structure.
string check_types
if `True` (default) types of sequences are checked as well, including the keys of dictionaries. If set to `False`, for example a list and a tuple of objects will look the same if they have the same size. Note that namedtuples with identical name and fields are always considered to have the same shallow structure. Two types will also be considered the same if they are both list subtypes (which allows "list" and "_ListWrapper" from trackable dependency tracking to compare equal).
ImplicitContainer<T> expand_composites
If true, then composite tensors such as tf.SparseTensor and tf.RaggedTensor are expanded into their component tensors.
Show Example
def nt(a, b):
              return collections.namedtuple('foo', 'a b')(a, b)
            print(assert_same_structure(nt(0, 1), nt(2, 3))) 

void assert_same_structure(IEnumerable<IGraphNodeBase> nest1, PythonFunctionContainer nest2, string check_types, ImplicitContainer<T> expand_composites)

Asserts that two structures are nested in the same way.

Note that namedtuples with identical name and fields are always considered to have the same shallow structure (even with `check_types=True`). For instance, this code will print `True`:
Parameters
IEnumerable<IGraphNodeBase> nest1
an arbitrarily nested structure.
PythonFunctionContainer nest2
an arbitrarily nested structure.
string check_types
if `True` (default) types of sequences are checked as well, including the keys of dictionaries. If set to `False`, for example a list and a tuple of objects will look the same if they have the same size. Note that namedtuples with identical name and fields are always considered to have the same shallow structure. Two types will also be considered the same if they are both list subtypes (which allows "list" and "_ListWrapper" from trackable dependency tracking to compare equal).
ImplicitContainer<T> expand_composites
If true, then composite tensors such as tf.SparseTensor and tf.RaggedTensor are expanded into their component tensors.
Show Example
def nt(a, b):
              return collections.namedtuple('foo', 'a b')(a, b)
            print(assert_same_structure(nt(0, 1), nt(2, 3))) 

object assert_same_structure_dyn(object nest1, object nest2, ImplicitContainer<T> check_types, ImplicitContainer<T> expand_composites)

Asserts that two structures are nested in the same way.

Note that namedtuples with identical name and fields are always considered to have the same shallow structure (even with `check_types=True`). For instance, this code will print `True`:
Parameters
object nest1
an arbitrarily nested structure.
object nest2
an arbitrarily nested structure.
ImplicitContainer<T> check_types
if `True` (default) types of sequences are checked as well, including the keys of dictionaries. If set to `False`, for example a list and a tuple of objects will look the same if they have the same size. Note that namedtuples with identical name and fields are always considered to have the same shallow structure. Two types will also be considered the same if they are both list subtypes (which allows "list" and "_ListWrapper" from trackable dependency tracking to compare equal).
ImplicitContainer<T> expand_composites
If true, then composite tensors such as tf.SparseTensor and tf.RaggedTensor are expanded into their component tensors.
Show Example
def nt(a, b):
              return collections.namedtuple('foo', 'a b')(a, b)
            print(assert_same_structure(nt(0, 1), nt(2, 3))) 

object flatten(object structure, string expand_composites)

Returns a flat list from a given nested structure.

If nest is not a sequence, tuple, or dict, then returns a single-element list: [nest].

In the case of dict instances, the sequence consists of the values, sorted by key to ensure deterministic behavior. 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 pack_sequence_as. 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.

Users must not modify any collections used in nest while this function is running.
Parameters
object structure
an arbitrarily nested structure or a scalar object. Note, numpy arrays are considered scalars.
string expand_composites
If true, then composite tensors such as tf.SparseTensor and tf.RaggedTensor are expanded into their component tensors.
Returns
object
A Python list, the flattened version of the input.

object flatten(object structure, bool expand_composites)

Returns a flat list from a given nested structure.

If nest is not a sequence, tuple, or dict, then returns a single-element list: [nest].

In the case of dict instances, the sequence consists of the values, sorted by key to ensure deterministic behavior. 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 pack_sequence_as. 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.

Users must not modify any collections used in nest while this function is running.
Parameters
object structure
an arbitrarily nested structure or a scalar object. Note, numpy arrays are considered scalars.
bool expand_composites
If true, then composite tensors such as tf.SparseTensor and tf.RaggedTensor are expanded into their component tensors.
Returns
object
A Python list, the flattened version of the input.

object flatten(PythonFunctionContainer structure, string expand_composites)

Returns a flat list from a given nested structure.

If nest is not a sequence, tuple, or dict, then returns a single-element list: [nest].

In the case of dict instances, the sequence consists of the values, sorted by key to ensure deterministic behavior. 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 pack_sequence_as. 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.

Users must not modify any collections used in nest while this function is running.
Parameters
PythonFunctionContainer structure
an arbitrarily nested structure or a scalar object. Note, numpy arrays are considered scalars.
string expand_composites
If true, then composite tensors such as tf.SparseTensor and tf.RaggedTensor are expanded into their component tensors.
Returns
object
A Python list, the flattened version of the input.

object flatten(PythonFunctionContainer structure, bool expand_composites)

Returns a flat list from a given nested structure.

If nest is not a sequence, tuple, or dict, then returns a single-element list: [nest].

In the case of dict instances, the sequence consists of the values, sorted by key to ensure deterministic behavior. 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 pack_sequence_as. 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.

Users must not modify any collections used in nest while this function is running.
Parameters
PythonFunctionContainer structure
an arbitrarily nested structure or a scalar object. Note, numpy arrays are considered scalars.
bool expand_composites
If true, then composite tensors such as tf.SparseTensor and tf.RaggedTensor are expanded into their component tensors.
Returns
object
A Python list, the flattened version of the input.

object flatten(IEnumerable<IGraphNodeBase> structure, string expand_composites)

Returns a flat list from a given nested structure.

If nest is not a sequence, tuple, or dict, then returns a single-element list: [nest].

In the case of dict instances, the sequence consists of the values, sorted by key to ensure deterministic behavior. 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 pack_sequence_as. 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.

Users must not modify any collections used in nest while this function is running.
Parameters
IEnumerable<IGraphNodeBase> structure
an arbitrarily nested structure or a scalar object. Note, numpy arrays are considered scalars.
string expand_composites
If true, then composite tensors such as tf.SparseTensor and tf.RaggedTensor are expanded into their component tensors.
Returns
object
A Python list, the flattened version of the input.

object flatten(IEnumerable<IGraphNodeBase> structure, bool expand_composites)

Returns a flat list from a given nested structure.

If nest is not a sequence, tuple, or dict, then returns a single-element list: [nest].

In the case of dict instances, the sequence consists of the values, sorted by key to ensure deterministic behavior. 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 pack_sequence_as. 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.

Users must not modify any collections used in nest while this function is running.
Parameters
IEnumerable<IGraphNodeBase> structure
an arbitrarily nested structure or a scalar object. Note, numpy arrays are considered scalars.
bool expand_composites
If true, then composite tensors such as tf.SparseTensor and tf.RaggedTensor are expanded into their component tensors.
Returns
object
A Python list, the flattened version of the input.

object flatten_dyn(object structure, ImplicitContainer<T> expand_composites)

Returns a flat list from a given nested structure.

If nest is not a sequence, tuple, or dict, then returns a single-element list: [nest].

In the case of dict instances, the sequence consists of the values, sorted by key to ensure deterministic behavior. 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 pack_sequence_as. 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.

Users must not modify any collections used in nest while this function is running.
Parameters
object structure
an arbitrarily nested structure or a scalar object. Note, numpy arrays are considered scalars.
ImplicitContainer<T> expand_composites
If true, then composite tensors such as tf.SparseTensor and tf.RaggedTensor are expanded into their component tensors.
Returns
object
A Python list, the flattened version of the input.

object is_nested(object seq)

Returns true if its input is a collections.abc.Sequence (except strings).
Parameters
object seq
an input sequence.
Returns
object
True if the sequence is a not a string and is a collections.abc.Sequence or a dict.

object is_nested_dyn(object seq)

Returns true if its input is a collections.abc.Sequence (except strings).
Parameters
object seq
an input sequence.
Returns
object
True if the sequence is a not a string and is a collections.abc.Sequence or a dict.

object pack_sequence_as(PythonFunctionContainer structure, PythonClassContainer flat_sequence, bool expand_composites)

Returns a given flattened sequence packed into a given structure.

If `structure` is a scalar, `flat_sequence` must be a single-element list; in this case the return value is `flat_sequence[0]`.

If `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 `flatten`. This correctly repacks dicts and `OrderedDict`s 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.
Parameters
PythonFunctionContainer structure
Nested structure, whose structure is given by nested lists, tuples, and dicts. Note: numpy arrays and strings are considered scalars.
PythonClassContainer flat_sequence
flat sequence to pack.
bool expand_composites
If true, then composite tensors such as tf.SparseTensor and tf.RaggedTensor are expanded into their component tensors.
Returns
object

object pack_sequence_as(IEnumerable<IGraphNodeBase> structure, IEnumerable<object> flat_sequence, bool expand_composites)

Returns a given flattened sequence packed into a given structure.

If `structure` is a scalar, `flat_sequence` must be a single-element list; in this case the return value is `flat_sequence[0]`.

If `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 `flatten`. This correctly repacks dicts and `OrderedDict`s 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.
Parameters
IEnumerable<IGraphNodeBase> structure
Nested structure, whose structure is given by nested lists, tuples, and dicts. Note: numpy arrays and strings are considered scalars.
IEnumerable<object> flat_sequence
flat sequence to pack.
bool expand_composites
If true, then composite tensors such as tf.SparseTensor and tf.RaggedTensor are expanded into their component tensors.
Returns
object

object pack_sequence_as(IEnumerable<IGraphNodeBase> structure, IEnumerable<object> flat_sequence, string expand_composites)

Returns a given flattened sequence packed into a given structure.

If `structure` is a scalar, `flat_sequence` must be a single-element list; in this case the return value is `flat_sequence[0]`.

If `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 `flatten`. This correctly repacks dicts and `OrderedDict`s 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.
Parameters
IEnumerable<IGraphNodeBase> structure
Nested structure, whose structure is given by nested lists, tuples, and dicts. Note: numpy arrays and strings are considered scalars.
IEnumerable<object> flat_sequence
flat sequence to pack.
string expand_composites
If true, then composite tensors such as tf.SparseTensor and tf.RaggedTensor are expanded into their component tensors.
Returns
object

object pack_sequence_as(IEnumerable<IGraphNodeBase> structure, PythonClassContainer flat_sequence, bool expand_composites)

Returns a given flattened sequence packed into a given structure.

If `structure` is a scalar, `flat_sequence` must be a single-element list; in this case the return value is `flat_sequence[0]`.

If `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 `flatten`. This correctly repacks dicts and `OrderedDict`s 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.
Parameters
IEnumerable<IGraphNodeBase> structure
Nested structure, whose structure is given by nested lists, tuples, and dicts. Note: numpy arrays and strings are considered scalars.
PythonClassContainer flat_sequence
flat sequence to pack.
bool expand_composites
If true, then composite tensors such as tf.SparseTensor and tf.RaggedTensor are expanded into their component tensors.
Returns
object

object pack_sequence_as(IEnumerable<IGraphNodeBase> structure, PythonClassContainer flat_sequence, string expand_composites)

Returns a given flattened sequence packed into a given structure.

If `structure` is a scalar, `flat_sequence` must be a single-element list; in this case the return value is `flat_sequence[0]`.

If `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 `flatten`. This correctly repacks dicts and `OrderedDict`s 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.
Parameters
IEnumerable<IGraphNodeBase> structure
Nested structure, whose structure is given by nested lists, tuples, and dicts. Note: numpy arrays and strings are considered scalars.
PythonClassContainer flat_sequence
flat sequence to pack.
string expand_composites
If true, then composite tensors such as tf.SparseTensor and tf.RaggedTensor are expanded into their component tensors.
Returns
object

object pack_sequence_as(IEnumerable<IGraphNodeBase> structure, object flat_sequence, string expand_composites)

Returns a given flattened sequence packed into a given structure.

If `structure` is a scalar, `flat_sequence` must be a single-element list; in this case the return value is `flat_sequence[0]`.

If `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 `flatten`. This correctly repacks dicts and `OrderedDict`s 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.
Parameters
IEnumerable<IGraphNodeBase> structure
Nested structure, whose structure is given by nested lists, tuples, and dicts. Note: numpy arrays and strings are considered scalars.
object flat_sequence
flat sequence to pack.
string expand_composites
If true, then composite tensors such as tf.SparseTensor and tf.RaggedTensor are expanded into their component tensors.
Returns
object

object pack_sequence_as(PythonFunctionContainer structure, IEnumerable<object> flat_sequence, bool expand_composites)

Returns a given flattened sequence packed into a given structure.

If `structure` is a scalar, `flat_sequence` must be a single-element list; in this case the return value is `flat_sequence[0]`.

If `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 `flatten`. This correctly repacks dicts and `OrderedDict`s 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.
Parameters
PythonFunctionContainer structure
Nested structure, whose structure is given by nested lists, tuples, and dicts. Note: numpy arrays and strings are considered scalars.
IEnumerable<object> flat_sequence
flat sequence to pack.
bool expand_composites
If true, then composite tensors such as tf.SparseTensor and tf.RaggedTensor are expanded into their component tensors.
Returns
object

object pack_sequence_as(PythonFunctionContainer structure, IEnumerable<object> flat_sequence, string expand_composites)

Returns a given flattened sequence packed into a given structure.

If `structure` is a scalar, `flat_sequence` must be a single-element list; in this case the return value is `flat_sequence[0]`.

If `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 `flatten`. This correctly repacks dicts and `OrderedDict`s 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.
Parameters
PythonFunctionContainer structure
Nested structure, whose structure is given by nested lists, tuples, and dicts. Note: numpy arrays and strings are considered scalars.
IEnumerable<object> flat_sequence
flat sequence to pack.
string expand_composites
If true, then composite tensors such as tf.SparseTensor and tf.RaggedTensor are expanded into their component tensors.
Returns
object

object pack_sequence_as(object structure, object flat_sequence, string expand_composites)

Returns a given flattened sequence packed into a given structure.

If `structure` is a scalar, `flat_sequence` must be a single-element list; in this case the return value is `flat_sequence[0]`.

If `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 `flatten`. This correctly repacks dicts and `OrderedDict`s 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.
Parameters
object structure
Nested structure, whose structure is given by nested lists, tuples, and dicts. Note: numpy arrays and strings are considered scalars.
object flat_sequence
flat sequence to pack.
string expand_composites
If true, then composite tensors such as tf.SparseTensor and tf.RaggedTensor are expanded into their component tensors.
Returns
object

object pack_sequence_as(object structure, PythonClassContainer flat_sequence, string expand_composites)

Returns a given flattened sequence packed into a given structure.

If `structure` is a scalar, `flat_sequence` must be a single-element list; in this case the return value is `flat_sequence[0]`.

If `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 `flatten`. This correctly repacks dicts and `OrderedDict`s 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.
Parameters
object structure
Nested structure, whose structure is given by nested lists, tuples, and dicts. Note: numpy arrays and strings are considered scalars.
PythonClassContainer flat_sequence
flat sequence to pack.
string expand_composites
If true, then composite tensors such as tf.SparseTensor and tf.RaggedTensor are expanded into their component tensors.
Returns
object

object pack_sequence_as(object structure, PythonClassContainer flat_sequence, bool expand_composites)

Returns a given flattened sequence packed into a given structure.

If `structure` is a scalar, `flat_sequence` must be a single-element list; in this case the return value is `flat_sequence[0]`.

If `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 `flatten`. This correctly repacks dicts and `OrderedDict`s 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.
Parameters
object structure
Nested structure, whose structure is given by nested lists, tuples, and dicts. Note: numpy arrays and strings are considered scalars.
PythonClassContainer flat_sequence
flat sequence to pack.
bool expand_composites
If true, then composite tensors such as tf.SparseTensor and tf.RaggedTensor are expanded into their component tensors.
Returns
object

object pack_sequence_as(object structure, IEnumerable<object> flat_sequence, string expand_composites)

Returns a given flattened sequence packed into a given structure.

If `structure` is a scalar, `flat_sequence` must be a single-element list; in this case the return value is `flat_sequence[0]`.

If `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 `flatten`. This correctly repacks dicts and `OrderedDict`s 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.
Parameters
object structure
Nested structure, whose structure is given by nested lists, tuples, and dicts. Note: numpy arrays and strings are considered scalars.
IEnumerable<object> flat_sequence
flat sequence to pack.
string expand_composites
If true, then composite tensors such as tf.SparseTensor and tf.RaggedTensor are expanded into their component tensors.
Returns
object

object pack_sequence_as(object structure, IEnumerable<object> flat_sequence, bool expand_composites)

Returns a given flattened sequence packed into a given structure.

If `structure` is a scalar, `flat_sequence` must be a single-element list; in this case the return value is `flat_sequence[0]`.

If `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 `flatten`. This correctly repacks dicts and `OrderedDict`s 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.
Parameters
object structure
Nested structure, whose structure is given by nested lists, tuples, and dicts. Note: numpy arrays and strings are considered scalars.
IEnumerable<object> flat_sequence
flat sequence to pack.
bool expand_composites
If true, then composite tensors such as tf.SparseTensor and tf.RaggedTensor are expanded into their component tensors.
Returns
object

object pack_sequence_as(PythonFunctionContainer structure, object flat_sequence, string expand_composites)

Returns a given flattened sequence packed into a given structure.

If `structure` is a scalar, `flat_sequence` must be a single-element list; in this case the return value is `flat_sequence[0]`.

If `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 `flatten`. This correctly repacks dicts and `OrderedDict`s 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.
Parameters
PythonFunctionContainer structure
Nested structure, whose structure is given by nested lists, tuples, and dicts. Note: numpy arrays and strings are considered scalars.
object flat_sequence
flat sequence to pack.
string expand_composites
If true, then composite tensors such as tf.SparseTensor and tf.RaggedTensor are expanded into their component tensors.
Returns
object

object pack_sequence_as(PythonFunctionContainer structure, object flat_sequence, bool expand_composites)

Returns a given flattened sequence packed into a given structure.

If `structure` is a scalar, `flat_sequence` must be a single-element list; in this case the return value is `flat_sequence[0]`.

If `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 `flatten`. This correctly repacks dicts and `OrderedDict`s 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.
Parameters
PythonFunctionContainer structure
Nested structure, whose structure is given by nested lists, tuples, and dicts. Note: numpy arrays and strings are considered scalars.
object flat_sequence
flat sequence to pack.
bool expand_composites
If true, then composite tensors such as tf.SparseTensor and tf.RaggedTensor are expanded into their component tensors.
Returns
object

object pack_sequence_as(PythonFunctionContainer structure, PythonClassContainer flat_sequence, string expand_composites)

Returns a given flattened sequence packed into a given structure.

If `structure` is a scalar, `flat_sequence` must be a single-element list; in this case the return value is `flat_sequence[0]`.

If `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 `flatten`. This correctly repacks dicts and `OrderedDict`s 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.
Parameters
PythonFunctionContainer structure
Nested structure, whose structure is given by nested lists, tuples, and dicts. Note: numpy arrays and strings are considered scalars.
PythonClassContainer flat_sequence
flat sequence to pack.
string expand_composites
If true, then composite tensors such as tf.SparseTensor and tf.RaggedTensor are expanded into their component tensors.
Returns
object

object pack_sequence_as(object structure, object flat_sequence, bool expand_composites)

Returns a given flattened sequence packed into a given structure.

If `structure` is a scalar, `flat_sequence` must be a single-element list; in this case the return value is `flat_sequence[0]`.

If `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 `flatten`. This correctly repacks dicts and `OrderedDict`s 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.
Parameters
object structure
Nested structure, whose structure is given by nested lists, tuples, and dicts. Note: numpy arrays and strings are considered scalars.
object flat_sequence
flat sequence to pack.
bool expand_composites
If true, then composite tensors such as tf.SparseTensor and tf.RaggedTensor are expanded into their component tensors.
Returns
object

object pack_sequence_as(IEnumerable<IGraphNodeBase> structure, object flat_sequence, bool expand_composites)

Returns a given flattened sequence packed into a given structure.

If `structure` is a scalar, `flat_sequence` must be a single-element list; in this case the return value is `flat_sequence[0]`.

If `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 `flatten`. This correctly repacks dicts and `OrderedDict`s 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.
Parameters
IEnumerable<IGraphNodeBase> structure
Nested structure, whose structure is given by nested lists, tuples, and dicts. Note: numpy arrays and strings are considered scalars.
object flat_sequence
flat sequence to pack.
bool expand_composites
If true, then composite tensors such as tf.SparseTensor and tf.RaggedTensor are expanded into their component tensors.
Returns
object

object pack_sequence_as_dyn(object structure, object flat_sequence, ImplicitContainer<T> expand_composites)

Returns a given flattened sequence packed into a given structure.

If `structure` is a scalar, `flat_sequence` must be a single-element list; in this case the return value is `flat_sequence[0]`.

If `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 `flatten`. This correctly repacks dicts and `OrderedDict`s 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.
Parameters
object structure
Nested structure, whose structure is given by nested lists, tuples, and dicts. Note: numpy arrays and strings are considered scalars.
object flat_sequence
flat sequence to pack.
ImplicitContainer<T> expand_composites
If true, then composite tensors such as tf.SparseTensor and tf.RaggedTensor are expanded into their component tensors.
Returns
object

Public properties

PythonFunctionContainer assert_same_structure_fn get;

PythonFunctionContainer flatten_fn get;

PythonFunctionContainer is_nested_fn get;

PythonFunctionContainer map_structure_fn get;

PythonFunctionContainer pack_sequence_as_fn get;