fix indentation
This commit is contained in:
parent
bf967f19ab
commit
f30aedc0e0
@ -122,8 +122,8 @@ def dense_to_sparse_batch(batch_size, row_shape):
|
||||
row_shape: A `tf.TensorShape` or `tf.int64` vector tensor-like object
|
||||
representing the equivalent dense shape of a row in the resulting
|
||||
`tf.sparse.SparseTensor`. Each element of this dataset must have the same
|
||||
rank as `row_shape`, and must have size less than or equal to
|
||||
`row_shape` in each dimension.
|
||||
rank as `row_shape`, and must have size less than or equal to
|
||||
`row_shape` in each dimension.
|
||||
|
||||
Returns:
|
||||
A `Dataset` transformation function, which can be passed to
|
||||
|
@ -66,7 +66,7 @@ def as_dense_types(types, classes):
|
||||
Returns:
|
||||
a structure matching the nested structure of `types`, containing
|
||||
`dtypes.variant` at positions where `classes` contains
|
||||
`tf.sparse.SparseTensor` and matching contents of `types` otherwise
|
||||
`tf.sparse.SparseTensor` and matching contents of `types` otherwise
|
||||
"""
|
||||
ret = nest.pack_sequence_as(types, [
|
||||
dtypes.variant if c is sparse_tensor.SparseTensor else ty
|
||||
@ -107,7 +107,7 @@ def get_classes(tensors):
|
||||
Returns:
|
||||
a structure matching the nested structure of `tensors`, containing
|
||||
`tf.sparse.SparseTensor` at positions where `tensors` contains a sparse
|
||||
tensor and `tf.Tensor` otherwise.
|
||||
tensor and `tf.Tensor` otherwise.
|
||||
"""
|
||||
return nest.pack_sequence_as(tensors, [
|
||||
sparse_tensor.SparseTensor
|
||||
|
@ -169,7 +169,7 @@ def set_intersection(a, b, validate_indices=True):
|
||||
((1, 1, 3), 8),
|
||||
])
|
||||
b = tf.sparse.SparseTensor(list(b.keys()), list(b.values()),
|
||||
dense_shape=[2, 2, 4])
|
||||
dense_shape=[2, 2, 4])
|
||||
|
||||
# `tf.sets.intersection` is applied to each aligned pair of sets.
|
||||
tf.sets.intersection(a, b)
|
||||
@ -227,7 +227,7 @@ def set_difference(a, b, aminusb=True, validate_indices=True):
|
||||
((1, 1, 1), 6),
|
||||
])
|
||||
a = tf.sparse.SparseTensor(list(a.keys()), list(a.values()),
|
||||
dense_shape=[2, 2, 2])
|
||||
dense_shape=[2, 2, 2])
|
||||
|
||||
# np.array([[{1, 3}, {2}], [{4, 5}, {5, 6, 7, 8}]])
|
||||
b = collections.OrderedDict([
|
||||
@ -242,7 +242,7 @@ def set_difference(a, b, aminusb=True, validate_indices=True):
|
||||
((1, 1, 3), 8),
|
||||
])
|
||||
b = tf.sparse.SparseTensor(list(b.keys()), list(b.values()),
|
||||
dense_shape=[2, 2, 4])
|
||||
dense_shape=[2, 2, 4])
|
||||
|
||||
# `set_difference` is applied to each aligned pair of sets.
|
||||
tf.sets.difference(a, b)
|
||||
@ -307,7 +307,7 @@ def set_union(a, b, validate_indices=True):
|
||||
((1, 1, 1), 6),
|
||||
])
|
||||
a = tf.sparse.SparseTensor(list(a.keys()), list(a.values()),
|
||||
dense_shape=[2, 2, 2])
|
||||
dense_shape=[2, 2, 2])
|
||||
|
||||
# [[{1, 3}, {2}], [{4, 5}, {5, 6, 7, 8}]]
|
||||
b = collections.OrderedDict([
|
||||
@ -322,7 +322,7 @@ def set_union(a, b, validate_indices=True):
|
||||
((1, 1, 3), 8),
|
||||
])
|
||||
b = tf.sparse.SparseTensor(list(b.keys()), list(b.values()),
|
||||
dense_shape=[2, 2, 4])
|
||||
dense_shape=[2, 2, 4])
|
||||
|
||||
# `set_union` is applied to each aligned pair of sets.
|
||||
tf.sets.union(a, b)
|
||||
|
@ -311,7 +311,7 @@ def flatten(structure, expand_composites=False):
|
||||
structure: an arbitrarily nested structure. Note, numpy arrays are
|
||||
considered atoms and are not flattened.
|
||||
expand_composites: If true, then composite tensors such as
|
||||
tf.sparse.SparseTensor and tf.RaggedTensor are expanded into their
|
||||
`tf.sparse.SparseTensor` and `tf.RaggedTensor` are expanded into their
|
||||
component tensors.
|
||||
|
||||
Returns:
|
||||
@ -358,15 +358,15 @@ def assert_same_structure(nest1, nest2, check_types=True,
|
||||
nest1: an arbitrarily nested structure.
|
||||
nest2: an arbitrarily nested structure.
|
||||
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).
|
||||
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).
|
||||
expand_composites: If true, then composite tensors such as
|
||||
`tf.sparse.SparseTensor` and `tf.RaggedTensor` are expanded into their
|
||||
`tf.sparse.SparseTensor` and `tf.RaggedTensor` are expanded into their
|
||||
component tensors.
|
||||
|
||||
Raises:
|
||||
@ -536,11 +536,11 @@ def pack_sequence_as(structure, flat_sequence, expand_composites=False):
|
||||
|
||||
Args:
|
||||
structure: Nested structure, whose structure is given by nested lists,
|
||||
tuples, and dicts. Note: numpy arrays and strings are considered
|
||||
scalars.
|
||||
tuples, and dicts. Note: numpy arrays and strings are considered
|
||||
scalars.
|
||||
flat_sequence: flat sequence to pack.
|
||||
expand_composites: If true, then composite tensors such as
|
||||
`tf.sparse.SparseTensor` and `tf.RaggedTensor` are expanded into their
|
||||
`tf.sparse.SparseTensor` and `tf.RaggedTensor` are expanded into their
|
||||
component tensors.
|
||||
|
||||
Returns:
|
||||
@ -578,8 +578,8 @@ def map_structure(func, *structure, **kwargs):
|
||||
considered to have the same shallow structure.
|
||||
* `expand_composites`: If set to `True`, then composite tensors such
|
||||
as `tf.sparse.SparseTensor` and `tf.RaggedTensor` are expanded into
|
||||
their component tensors. If `False` (the default), then composite
|
||||
tensors are not expanded.
|
||||
their component tensors. If `False` (the default), then composite
|
||||
tensors are not expanded.
|
||||
|
||||
Returns:
|
||||
A new structure with the same arity as `structure`, whose values correspond
|
||||
@ -766,7 +766,7 @@ def assert_shallow_structure(shallow_tree,
|
||||
this function will consider two different namedtuple classes with the same
|
||||
name and _fields attribute to be the same class.
|
||||
expand_composites: If true, then composite tensors such as
|
||||
tf.sparse.SparseTensor and tf.RaggedTensor are expanded into their
|
||||
`tf.sparse.SparseTensor` and `tf.RaggedTensor` are expanded into their
|
||||
component tensors.
|
||||
Raises:
|
||||
TypeError: If `shallow_tree` is a sequence but `input_tree` is not.
|
||||
@ -916,7 +916,7 @@ def flatten_up_to(shallow_tree, input_tree, check_types=True,
|
||||
check_types: bool. If True, check that each node in shallow_tree has the
|
||||
same type as the corresponding node in input_tree.
|
||||
expand_composites: If true, then composite tensors such as
|
||||
tf.sparse.SparseTensor and tf.RaggedTensor are expanded into their
|
||||
`tf.sparse.SparseTensor` and `tf.RaggedTensor` are expanded into their
|
||||
component tensors.
|
||||
|
||||
Returns:
|
||||
@ -1021,7 +1021,7 @@ def flatten_with_tuple_paths_up_to(shallow_tree,
|
||||
check_types: bool. If True, check that each node in shallow_tree has the
|
||||
same type as the corresponding node in input_tree.
|
||||
expand_composites: If true, then composite tensors such as
|
||||
tf.sparse.SparseTensor and tf.RaggedTensor are expanded into their
|
||||
`tf.sparse.SparseTensor` and `tf.RaggedTensor` are expanded into their
|
||||
component tensors.
|
||||
|
||||
Returns:
|
||||
@ -1240,7 +1240,7 @@ def get_traverse_shallow_structure(traverse_fn, structure,
|
||||
substructure to traverse.
|
||||
structure: The structure to traverse.
|
||||
expand_composites: If true, then composite tensors such as
|
||||
tf.sparse.SparseTensor and tf.RaggedTensor are expanded into their
|
||||
`tf.sparse.SparseTensor` and `tf.RaggedTensor` are expanded into their
|
||||
component tensors.
|
||||
|
||||
Returns:
|
||||
@ -1321,12 +1321,12 @@ def yield_flat_paths(nest, expand_composites=False):
|
||||
Args:
|
||||
nest: the value to produce a flattened paths list for.
|
||||
expand_composites: If true, then composite tensors such as
|
||||
tf.sparse.SparseTensor and tf.RaggedTensor are expanded into their
|
||||
`tf.sparse.SparseTensor` and `tf.RaggedTensor` are expanded into their
|
||||
component tensors.
|
||||
|
||||
Yields:
|
||||
Tuples containing index or key values which form the path to a specific
|
||||
leaf value in the nested structure.
|
||||
leaf value in the nested structure.
|
||||
"""
|
||||
is_seq = is_sequence_or_composite if expand_composites else is_sequence
|
||||
for k, _ in _yield_flat_up_to(nest, nest, is_seq):
|
||||
@ -1347,7 +1347,7 @@ def flatten_with_joined_string_paths(structure, separator="/",
|
||||
separator: string to separate levels of hierarchy in the results, defaults
|
||||
to '/'.
|
||||
expand_composites: If true, then composite tensors such as
|
||||
tf.sparse.SparseTensor and tf.RaggedTensor are expanded into their
|
||||
`tf.sparse.SparseTensor` and `tf.RaggedTensor` are expanded into their
|
||||
component tensors.
|
||||
|
||||
Returns:
|
||||
@ -1372,7 +1372,7 @@ def flatten_with_tuple_paths(structure, expand_composites=False):
|
||||
Args:
|
||||
structure: the nested structure to flatten.
|
||||
expand_composites: If true, then composite tensors such as
|
||||
tf.sparse.SparseTensor and tf.RaggedTensor are expanded into their
|
||||
`tf.sparse.SparseTensor` and `tf.RaggedTensor` are expanded into their
|
||||
component tensors.
|
||||
|
||||
Returns:
|
||||
|
Loading…
x
Reference in New Issue
Block a user