Type tf.sets
Namespace tensorflow
Methods
- difference
- difference
- difference
- difference
- difference
- difference
- difference
- difference
- difference
- difference
- difference
- difference
- difference
- difference
- difference
- difference_dyn
- intersection
- intersection
- intersection
- intersection
- intersection
- intersection
- intersection
- intersection
- intersection
- intersection
- intersection
- intersection
- intersection
- intersection
- intersection
- intersection
- intersection
- intersection
- intersection_dyn
- size
- size_dyn
- union
- union_dyn
Properties
Public static methods
SparseTensor difference(IGraphNodeBase a, object b, bool aminusb, bool validate_indices)
Compute set difference of elements in last dimension of `a` and `b`. All but the last dimension of `a` and `b` must match. Example:
Parameters
-
IGraphNodeBasea - `Tensor` or `SparseTensor` of the same type as `b`. If sparse, indices must be sorted in row-major order.
-
objectb - `Tensor` or `SparseTensor` of the same type as `a`. If sparse, indices must be sorted in row-major order.
-
boolaminusb - Whether to subtract `b` from `a`, vs vice versa.
-
boolvalidate_indices - Whether to validate the order and range of sparse indices in `a` and `b`.
Returns
-
SparseTensor - A `SparseTensor` whose shape is the same rank as `a` and `b`, and all but the last dimension the same. Elements along the last dimension contain the differences.
Show Example
import tensorflow as tf
import collections # Represent the following array of sets as a sparse tensor:
# a = np.array([[{1, 2}, {3}], [{4}, {5, 6}]])
a = collections.OrderedDict([
((0, 0, 0), 1),
((0, 0, 1), 2),
((0, 1, 0), 3),
((1, 0, 0), 4),
((1, 1, 0), 5),
((1, 1, 1), 6),
])
a = tf.SparseTensor(list(a.keys()), list(a.values()), dense_shape=[2, 2, 2]) # np.array([[{1, 3}, {2}], [{4, 5}, {5, 6, 7, 8}]])
b = collections.OrderedDict([
((0, 0, 0), 1),
((0, 0, 1), 3),
((0, 1, 0), 2),
((1, 0, 0), 4),
((1, 0, 1), 5),
((1, 1, 0), 5),
((1, 1, 1), 6),
((1, 1, 2), 7),
((1, 1, 3), 8),
])
b = tf.SparseTensor(list(b.keys()), list(b.values()), dense_shape=[2, 2, 4]) # `set_difference` is applied to each aligned pair of sets.
tf.sets.difference(a, b) # The result will be equivalent to either of:
#
# np.array([[{2}, {3}], [{}, {}]])
#
# collections.OrderedDict([
# ((0, 0, 0), 2),
# ((0, 1, 0), 3),
# ])
SparseTensor difference(IGraphNodeBase a, IEnumerable<object> b, bool aminusb, bool validate_indices)
Compute set difference of elements in last dimension of `a` and `b`. All but the last dimension of `a` and `b` must match. Example:
Parameters
-
IGraphNodeBasea - `Tensor` or `SparseTensor` of the same type as `b`. If sparse, indices must be sorted in row-major order.
-
IEnumerable<object>b - `Tensor` or `SparseTensor` of the same type as `a`. If sparse, indices must be sorted in row-major order.
-
boolaminusb - Whether to subtract `b` from `a`, vs vice versa.
-
boolvalidate_indices - Whether to validate the order and range of sparse indices in `a` and `b`.
Returns
-
SparseTensor - A `SparseTensor` whose shape is the same rank as `a` and `b`, and all but the last dimension the same. Elements along the last dimension contain the differences.
Show Example
import tensorflow as tf
import collections # Represent the following array of sets as a sparse tensor:
# a = np.array([[{1, 2}, {3}], [{4}, {5, 6}]])
a = collections.OrderedDict([
((0, 0, 0), 1),
((0, 0, 1), 2),
((0, 1, 0), 3),
((1, 0, 0), 4),
((1, 1, 0), 5),
((1, 1, 1), 6),
])
a = tf.SparseTensor(list(a.keys()), list(a.values()), dense_shape=[2, 2, 2]) # np.array([[{1, 3}, {2}], [{4, 5}, {5, 6, 7, 8}]])
b = collections.OrderedDict([
((0, 0, 0), 1),
((0, 0, 1), 3),
((0, 1, 0), 2),
((1, 0, 0), 4),
((1, 0, 1), 5),
((1, 1, 0), 5),
((1, 1, 1), 6),
((1, 1, 2), 7),
((1, 1, 3), 8),
])
b = tf.SparseTensor(list(b.keys()), list(b.values()), dense_shape=[2, 2, 4]) # `set_difference` is applied to each aligned pair of sets.
tf.sets.difference(a, b) # The result will be equivalent to either of:
#
# np.array([[{2}, {3}], [{}, {}]])
#
# collections.OrderedDict([
# ((0, 0, 0), 2),
# ((0, 1, 0), 3),
# ])
SparseTensor difference(IGraphNodeBase a, ndarray b, bool aminusb, bool validate_indices)
Compute set difference of elements in last dimension of `a` and `b`. All but the last dimension of `a` and `b` must match. Example:
Parameters
-
IGraphNodeBasea - `Tensor` or `SparseTensor` of the same type as `b`. If sparse, indices must be sorted in row-major order.
-
ndarrayb - `Tensor` or `SparseTensor` of the same type as `a`. If sparse, indices must be sorted in row-major order.
-
boolaminusb - Whether to subtract `b` from `a`, vs vice versa.
-
boolvalidate_indices - Whether to validate the order and range of sparse indices in `a` and `b`.
Returns
-
SparseTensor - A `SparseTensor` whose shape is the same rank as `a` and `b`, and all but the last dimension the same. Elements along the last dimension contain the differences.
Show Example
import tensorflow as tf
import collections # Represent the following array of sets as a sparse tensor:
# a = np.array([[{1, 2}, {3}], [{4}, {5, 6}]])
a = collections.OrderedDict([
((0, 0, 0), 1),
((0, 0, 1), 2),
((0, 1, 0), 3),
((1, 0, 0), 4),
((1, 1, 0), 5),
((1, 1, 1), 6),
])
a = tf.SparseTensor(list(a.keys()), list(a.values()), dense_shape=[2, 2, 2]) # np.array([[{1, 3}, {2}], [{4, 5}, {5, 6, 7, 8}]])
b = collections.OrderedDict([
((0, 0, 0), 1),
((0, 0, 1), 3),
((0, 1, 0), 2),
((1, 0, 0), 4),
((1, 0, 1), 5),
((1, 1, 0), 5),
((1, 1, 1), 6),
((1, 1, 2), 7),
((1, 1, 3), 8),
])
b = tf.SparseTensor(list(b.keys()), list(b.values()), dense_shape=[2, 2, 4]) # `set_difference` is applied to each aligned pair of sets.
tf.sets.difference(a, b) # The result will be equivalent to either of:
#
# np.array([[{2}, {3}], [{}, {}]])
#
# collections.OrderedDict([
# ((0, 0, 0), 2),
# ((0, 1, 0), 3),
# ])
SparseTensor difference(IndexedSlices a, object b, bool aminusb, bool validate_indices)
Compute set difference of elements in last dimension of `a` and `b`. All but the last dimension of `a` and `b` must match. Example:
Parameters
-
IndexedSlicesa - `Tensor` or `SparseTensor` of the same type as `b`. If sparse, indices must be sorted in row-major order.
-
objectb - `Tensor` or `SparseTensor` of the same type as `a`. If sparse, indices must be sorted in row-major order.
-
boolaminusb - Whether to subtract `b` from `a`, vs vice versa.
-
boolvalidate_indices - Whether to validate the order and range of sparse indices in `a` and `b`.
Returns
-
SparseTensor - A `SparseTensor` whose shape is the same rank as `a` and `b`, and all but the last dimension the same. Elements along the last dimension contain the differences.
Show Example
import tensorflow as tf
import collections # Represent the following array of sets as a sparse tensor:
# a = np.array([[{1, 2}, {3}], [{4}, {5, 6}]])
a = collections.OrderedDict([
((0, 0, 0), 1),
((0, 0, 1), 2),
((0, 1, 0), 3),
((1, 0, 0), 4),
((1, 1, 0), 5),
((1, 1, 1), 6),
])
a = tf.SparseTensor(list(a.keys()), list(a.values()), dense_shape=[2, 2, 2]) # np.array([[{1, 3}, {2}], [{4, 5}, {5, 6, 7, 8}]])
b = collections.OrderedDict([
((0, 0, 0), 1),
((0, 0, 1), 3),
((0, 1, 0), 2),
((1, 0, 0), 4),
((1, 0, 1), 5),
((1, 1, 0), 5),
((1, 1, 1), 6),
((1, 1, 2), 7),
((1, 1, 3), 8),
])
b = tf.SparseTensor(list(b.keys()), list(b.values()), dense_shape=[2, 2, 4]) # `set_difference` is applied to each aligned pair of sets.
tf.sets.difference(a, b) # The result will be equivalent to either of:
#
# np.array([[{2}, {3}], [{}, {}]])
#
# collections.OrderedDict([
# ((0, 0, 0), 2),
# ((0, 1, 0), 3),
# ])
SparseTensor difference(IndexedSlices a, IGraphNodeBase b, bool aminusb, bool validate_indices)
Compute set difference of elements in last dimension of `a` and `b`. All but the last dimension of `a` and `b` must match. Example:
Parameters
-
IndexedSlicesa - `Tensor` or `SparseTensor` of the same type as `b`. If sparse, indices must be sorted in row-major order.
-
IGraphNodeBaseb - `Tensor` or `SparseTensor` of the same type as `a`. If sparse, indices must be sorted in row-major order.
-
boolaminusb - Whether to subtract `b` from `a`, vs vice versa.
-
boolvalidate_indices - Whether to validate the order and range of sparse indices in `a` and `b`.
Returns
-
SparseTensor - A `SparseTensor` whose shape is the same rank as `a` and `b`, and all but the last dimension the same. Elements along the last dimension contain the differences.
Show Example
import tensorflow as tf
import collections # Represent the following array of sets as a sparse tensor:
# a = np.array([[{1, 2}, {3}], [{4}, {5, 6}]])
a = collections.OrderedDict([
((0, 0, 0), 1),
((0, 0, 1), 2),
((0, 1, 0), 3),
((1, 0, 0), 4),
((1, 1, 0), 5),
((1, 1, 1), 6),
])
a = tf.SparseTensor(list(a.keys()), list(a.values()), dense_shape=[2, 2, 2]) # np.array([[{1, 3}, {2}], [{4, 5}, {5, 6, 7, 8}]])
b = collections.OrderedDict([
((0, 0, 0), 1),
((0, 0, 1), 3),
((0, 1, 0), 2),
((1, 0, 0), 4),
((1, 0, 1), 5),
((1, 1, 0), 5),
((1, 1, 1), 6),
((1, 1, 2), 7),
((1, 1, 3), 8),
])
b = tf.SparseTensor(list(b.keys()), list(b.values()), dense_shape=[2, 2, 4]) # `set_difference` is applied to each aligned pair of sets.
tf.sets.difference(a, b) # The result will be equivalent to either of:
#
# np.array([[{2}, {3}], [{}, {}]])
#
# collections.OrderedDict([
# ((0, 0, 0), 2),
# ((0, 1, 0), 3),
# ])
SparseTensor difference(IndexedSlices a, ValueTuple<IEnumerable<object>, object> b, bool aminusb, bool validate_indices)
Compute set difference of elements in last dimension of `a` and `b`. All but the last dimension of `a` and `b` must match. Example:
Parameters
-
IndexedSlicesa - `Tensor` or `SparseTensor` of the same type as `b`. If sparse, indices must be sorted in row-major order.
-
ValueTuple<IEnumerable<object>, object>b - `Tensor` or `SparseTensor` of the same type as `a`. If sparse, indices must be sorted in row-major order.
-
boolaminusb - Whether to subtract `b` from `a`, vs vice versa.
-
boolvalidate_indices - Whether to validate the order and range of sparse indices in `a` and `b`.
Returns
-
SparseTensor - A `SparseTensor` whose shape is the same rank as `a` and `b`, and all but the last dimension the same. Elements along the last dimension contain the differences.
Show Example
import tensorflow as tf
import collections # Represent the following array of sets as a sparse tensor:
# a = np.array([[{1, 2}, {3}], [{4}, {5, 6}]])
a = collections.OrderedDict([
((0, 0, 0), 1),
((0, 0, 1), 2),
((0, 1, 0), 3),
((1, 0, 0), 4),
((1, 1, 0), 5),
((1, 1, 1), 6),
])
a = tf.SparseTensor(list(a.keys()), list(a.values()), dense_shape=[2, 2, 2]) # np.array([[{1, 3}, {2}], [{4, 5}, {5, 6, 7, 8}]])
b = collections.OrderedDict([
((0, 0, 0), 1),
((0, 0, 1), 3),
((0, 1, 0), 2),
((1, 0, 0), 4),
((1, 0, 1), 5),
((1, 1, 0), 5),
((1, 1, 1), 6),
((1, 1, 2), 7),
((1, 1, 3), 8),
])
b = tf.SparseTensor(list(b.keys()), list(b.values()), dense_shape=[2, 2, 4]) # `set_difference` is applied to each aligned pair of sets.
tf.sets.difference(a, b) # The result will be equivalent to either of:
#
# np.array([[{2}, {3}], [{}, {}]])
#
# collections.OrderedDict([
# ((0, 0, 0), 2),
# ((0, 1, 0), 3),
# ])
SparseTensor difference(IndexedSlices a, IEnumerable<object> b, bool aminusb, bool validate_indices)
Compute set difference of elements in last dimension of `a` and `b`. All but the last dimension of `a` and `b` must match. Example:
Parameters
-
IndexedSlicesa - `Tensor` or `SparseTensor` of the same type as `b`. If sparse, indices must be sorted in row-major order.
-
IEnumerable<object>b - `Tensor` or `SparseTensor` of the same type as `a`. If sparse, indices must be sorted in row-major order.
-
boolaminusb - Whether to subtract `b` from `a`, vs vice versa.
-
boolvalidate_indices - Whether to validate the order and range of sparse indices in `a` and `b`.
Returns
-
SparseTensor - A `SparseTensor` whose shape is the same rank as `a` and `b`, and all but the last dimension the same. Elements along the last dimension contain the differences.
Show Example
import tensorflow as tf
import collections # Represent the following array of sets as a sparse tensor:
# a = np.array([[{1, 2}, {3}], [{4}, {5, 6}]])
a = collections.OrderedDict([
((0, 0, 0), 1),
((0, 0, 1), 2),
((0, 1, 0), 3),
((1, 0, 0), 4),
((1, 1, 0), 5),
((1, 1, 1), 6),
])
a = tf.SparseTensor(list(a.keys()), list(a.values()), dense_shape=[2, 2, 2]) # np.array([[{1, 3}, {2}], [{4, 5}, {5, 6, 7, 8}]])
b = collections.OrderedDict([
((0, 0, 0), 1),
((0, 0, 1), 3),
((0, 1, 0), 2),
((1, 0, 0), 4),
((1, 0, 1), 5),
((1, 1, 0), 5),
((1, 1, 1), 6),
((1, 1, 2), 7),
((1, 1, 3), 8),
])
b = tf.SparseTensor(list(b.keys()), list(b.values()), dense_shape=[2, 2, 4]) # `set_difference` is applied to each aligned pair of sets.
tf.sets.difference(a, b) # The result will be equivalent to either of:
#
# np.array([[{2}, {3}], [{}, {}]])
#
# collections.OrderedDict([
# ((0, 0, 0), 2),
# ((0, 1, 0), 3),
# ])
SparseTensor difference(IndexedSlices a, ndarray b, bool aminusb, bool validate_indices)
Compute set difference of elements in last dimension of `a` and `b`. All but the last dimension of `a` and `b` must match. Example:
Parameters
-
IndexedSlicesa - `Tensor` or `SparseTensor` of the same type as `b`. If sparse, indices must be sorted in row-major order.
-
ndarrayb - `Tensor` or `SparseTensor` of the same type as `a`. If sparse, indices must be sorted in row-major order.
-
boolaminusb - Whether to subtract `b` from `a`, vs vice versa.
-
boolvalidate_indices - Whether to validate the order and range of sparse indices in `a` and `b`.
Returns
-
SparseTensor - A `SparseTensor` whose shape is the same rank as `a` and `b`, and all but the last dimension the same. Elements along the last dimension contain the differences.
Show Example
import tensorflow as tf
import collections # Represent the following array of sets as a sparse tensor:
# a = np.array([[{1, 2}, {3}], [{4}, {5, 6}]])
a = collections.OrderedDict([
((0, 0, 0), 1),
((0, 0, 1), 2),
((0, 1, 0), 3),
((1, 0, 0), 4),
((1, 1, 0), 5),
((1, 1, 1), 6),
])
a = tf.SparseTensor(list(a.keys()), list(a.values()), dense_shape=[2, 2, 2]) # np.array([[{1, 3}, {2}], [{4, 5}, {5, 6, 7, 8}]])
b = collections.OrderedDict([
((0, 0, 0), 1),
((0, 0, 1), 3),
((0, 1, 0), 2),
((1, 0, 0), 4),
((1, 0, 1), 5),
((1, 1, 0), 5),
((1, 1, 1), 6),
((1, 1, 2), 7),
((1, 1, 3), 8),
])
b = tf.SparseTensor(list(b.keys()), list(b.values()), dense_shape=[2, 2, 4]) # `set_difference` is applied to each aligned pair of sets.
tf.sets.difference(a, b) # The result will be equivalent to either of:
#
# np.array([[{2}, {3}], [{}, {}]])
#
# collections.OrderedDict([
# ((0, 0, 0), 2),
# ((0, 1, 0), 3),
# ])
SparseTensor difference(ValueTuple<PythonClassContainer, PythonClassContainer> a, object b, bool aminusb, bool validate_indices)
Compute set difference of elements in last dimension of `a` and `b`. All but the last dimension of `a` and `b` must match. Example:
Parameters
-
ValueTuple<PythonClassContainer, PythonClassContainer>a - `Tensor` or `SparseTensor` of the same type as `b`. If sparse, indices must be sorted in row-major order.
-
objectb - `Tensor` or `SparseTensor` of the same type as `a`. If sparse, indices must be sorted in row-major order.
-
boolaminusb - Whether to subtract `b` from `a`, vs vice versa.
-
boolvalidate_indices - Whether to validate the order and range of sparse indices in `a` and `b`.
Returns
-
SparseTensor - A `SparseTensor` whose shape is the same rank as `a` and `b`, and all but the last dimension the same. Elements along the last dimension contain the differences.
Show Example
import tensorflow as tf
import collections # Represent the following array of sets as a sparse tensor:
# a = np.array([[{1, 2}, {3}], [{4}, {5, 6}]])
a = collections.OrderedDict([
((0, 0, 0), 1),
((0, 0, 1), 2),
((0, 1, 0), 3),
((1, 0, 0), 4),
((1, 1, 0), 5),
((1, 1, 1), 6),
])
a = tf.SparseTensor(list(a.keys()), list(a.values()), dense_shape=[2, 2, 2]) # np.array([[{1, 3}, {2}], [{4, 5}, {5, 6, 7, 8}]])
b = collections.OrderedDict([
((0, 0, 0), 1),
((0, 0, 1), 3),
((0, 1, 0), 2),
((1, 0, 0), 4),
((1, 0, 1), 5),
((1, 1, 0), 5),
((1, 1, 1), 6),
((1, 1, 2), 7),
((1, 1, 3), 8),
])
b = tf.SparseTensor(list(b.keys()), list(b.values()), dense_shape=[2, 2, 4]) # `set_difference` is applied to each aligned pair of sets.
tf.sets.difference(a, b) # The result will be equivalent to either of:
#
# np.array([[{2}, {3}], [{}, {}]])
#
# collections.OrderedDict([
# ((0, 0, 0), 2),
# ((0, 1, 0), 3),
# ])
SparseTensor difference(ValueTuple<PythonClassContainer, PythonClassContainer> a, IGraphNodeBase b, bool aminusb, bool validate_indices)
Compute set difference of elements in last dimension of `a` and `b`. All but the last dimension of `a` and `b` must match. Example:
Parameters
-
ValueTuple<PythonClassContainer, PythonClassContainer>a - `Tensor` or `SparseTensor` of the same type as `b`. If sparse, indices must be sorted in row-major order.
-
IGraphNodeBaseb - `Tensor` or `SparseTensor` of the same type as `a`. If sparse, indices must be sorted in row-major order.
-
boolaminusb - Whether to subtract `b` from `a`, vs vice versa.
-
boolvalidate_indices - Whether to validate the order and range of sparse indices in `a` and `b`.
Returns
-
SparseTensor - A `SparseTensor` whose shape is the same rank as `a` and `b`, and all but the last dimension the same. Elements along the last dimension contain the differences.
Show Example
import tensorflow as tf
import collections # Represent the following array of sets as a sparse tensor:
# a = np.array([[{1, 2}, {3}], [{4}, {5, 6}]])
a = collections.OrderedDict([
((0, 0, 0), 1),
((0, 0, 1), 2),
((0, 1, 0), 3),
((1, 0, 0), 4),
((1, 1, 0), 5),
((1, 1, 1), 6),
])
a = tf.SparseTensor(list(a.keys()), list(a.values()), dense_shape=[2, 2, 2]) # np.array([[{1, 3}, {2}], [{4, 5}, {5, 6, 7, 8}]])
b = collections.OrderedDict([
((0, 0, 0), 1),
((0, 0, 1), 3),
((0, 1, 0), 2),
((1, 0, 0), 4),
((1, 0, 1), 5),
((1, 1, 0), 5),
((1, 1, 1), 6),
((1, 1, 2), 7),
((1, 1, 3), 8),
])
b = tf.SparseTensor(list(b.keys()), list(b.values()), dense_shape=[2, 2, 4]) # `set_difference` is applied to each aligned pair of sets.
tf.sets.difference(a, b) # The result will be equivalent to either of:
#
# np.array([[{2}, {3}], [{}, {}]])
#
# collections.OrderedDict([
# ((0, 0, 0), 2),
# ((0, 1, 0), 3),
# ])
SparseTensor difference(ValueTuple<PythonClassContainer, PythonClassContainer> a, ValueTuple<IEnumerable<object>, object> b, bool aminusb, bool validate_indices)
Compute set difference of elements in last dimension of `a` and `b`. All but the last dimension of `a` and `b` must match. Example:
Parameters
-
ValueTuple<PythonClassContainer, PythonClassContainer>a - `Tensor` or `SparseTensor` of the same type as `b`. If sparse, indices must be sorted in row-major order.
-
ValueTuple<IEnumerable<object>, object>b - `Tensor` or `SparseTensor` of the same type as `a`. If sparse, indices must be sorted in row-major order.
-
boolaminusb - Whether to subtract `b` from `a`, vs vice versa.
-
boolvalidate_indices - Whether to validate the order and range of sparse indices in `a` and `b`.
Returns
-
SparseTensor - A `SparseTensor` whose shape is the same rank as `a` and `b`, and all but the last dimension the same. Elements along the last dimension contain the differences.
Show Example
import tensorflow as tf
import collections # Represent the following array of sets as a sparse tensor:
# a = np.array([[{1, 2}, {3}], [{4}, {5, 6}]])
a = collections.OrderedDict([
((0, 0, 0), 1),
((0, 0, 1), 2),
((0, 1, 0), 3),
((1, 0, 0), 4),
((1, 1, 0), 5),
((1, 1, 1), 6),
])
a = tf.SparseTensor(list(a.keys()), list(a.values()), dense_shape=[2, 2, 2]) # np.array([[{1, 3}, {2}], [{4, 5}, {5, 6, 7, 8}]])
b = collections.OrderedDict([
((0, 0, 0), 1),
((0, 0, 1), 3),
((0, 1, 0), 2),
((1, 0, 0), 4),
((1, 0, 1), 5),
((1, 1, 0), 5),
((1, 1, 1), 6),
((1, 1, 2), 7),
((1, 1, 3), 8),
])
b = tf.SparseTensor(list(b.keys()), list(b.values()), dense_shape=[2, 2, 4]) # `set_difference` is applied to each aligned pair of sets.
tf.sets.difference(a, b) # The result will be equivalent to either of:
#
# np.array([[{2}, {3}], [{}, {}]])
#
# collections.OrderedDict([
# ((0, 0, 0), 2),
# ((0, 1, 0), 3),
# ])
SparseTensor difference(ValueTuple<PythonClassContainer, PythonClassContainer> a, IEnumerable<object> b, bool aminusb, bool validate_indices)
Compute set difference of elements in last dimension of `a` and `b`. All but the last dimension of `a` and `b` must match. Example:
Parameters
-
ValueTuple<PythonClassContainer, PythonClassContainer>a - `Tensor` or `SparseTensor` of the same type as `b`. If sparse, indices must be sorted in row-major order.
-
IEnumerable<object>b - `Tensor` or `SparseTensor` of the same type as `a`. If sparse, indices must be sorted in row-major order.
-
boolaminusb - Whether to subtract `b` from `a`, vs vice versa.
-
boolvalidate_indices - Whether to validate the order and range of sparse indices in `a` and `b`.
Returns
-
SparseTensor - A `SparseTensor` whose shape is the same rank as `a` and `b`, and all but the last dimension the same. Elements along the last dimension contain the differences.
Show Example
import tensorflow as tf
import collections # Represent the following array of sets as a sparse tensor:
# a = np.array([[{1, 2}, {3}], [{4}, {5, 6}]])
a = collections.OrderedDict([
((0, 0, 0), 1),
((0, 0, 1), 2),
((0, 1, 0), 3),
((1, 0, 0), 4),
((1, 1, 0), 5),
((1, 1, 1), 6),
])
a = tf.SparseTensor(list(a.keys()), list(a.values()), dense_shape=[2, 2, 2]) # np.array([[{1, 3}, {2}], [{4, 5}, {5, 6, 7, 8}]])
b = collections.OrderedDict([
((0, 0, 0), 1),
((0, 0, 1), 3),
((0, 1, 0), 2),
((1, 0, 0), 4),
((1, 0, 1), 5),
((1, 1, 0), 5),
((1, 1, 1), 6),
((1, 1, 2), 7),
((1, 1, 3), 8),
])
b = tf.SparseTensor(list(b.keys()), list(b.values()), dense_shape=[2, 2, 4]) # `set_difference` is applied to each aligned pair of sets.
tf.sets.difference(a, b) # The result will be equivalent to either of:
#
# np.array([[{2}, {3}], [{}, {}]])
#
# collections.OrderedDict([
# ((0, 0, 0), 2),
# ((0, 1, 0), 3),
# ])
SparseTensor difference(ValueTuple<PythonClassContainer, PythonClassContainer> a, ndarray b, bool aminusb, bool validate_indices)
Compute set difference of elements in last dimension of `a` and `b`. All but the last dimension of `a` and `b` must match. Example:
Parameters
-
ValueTuple<PythonClassContainer, PythonClassContainer>a - `Tensor` or `SparseTensor` of the same type as `b`. If sparse, indices must be sorted in row-major order.
-
ndarrayb - `Tensor` or `SparseTensor` of the same type as `a`. If sparse, indices must be sorted in row-major order.
-
boolaminusb - Whether to subtract `b` from `a`, vs vice versa.
-
boolvalidate_indices - Whether to validate the order and range of sparse indices in `a` and `b`.
Returns
-
SparseTensor - A `SparseTensor` whose shape is the same rank as `a` and `b`, and all but the last dimension the same. Elements along the last dimension contain the differences.
Show Example
import tensorflow as tf
import collections # Represent the following array of sets as a sparse tensor:
# a = np.array([[{1, 2}, {3}], [{4}, {5, 6}]])
a = collections.OrderedDict([
((0, 0, 0), 1),
((0, 0, 1), 2),
((0, 1, 0), 3),
((1, 0, 0), 4),
((1, 1, 0), 5),
((1, 1, 1), 6),
])
a = tf.SparseTensor(list(a.keys()), list(a.values()), dense_shape=[2, 2, 2]) # np.array([[{1, 3}, {2}], [{4, 5}, {5, 6, 7, 8}]])
b = collections.OrderedDict([
((0, 0, 0), 1),
((0, 0, 1), 3),
((0, 1, 0), 2),
((1, 0, 0), 4),
((1, 0, 1), 5),
((1, 1, 0), 5),
((1, 1, 1), 6),
((1, 1, 2), 7),
((1, 1, 3), 8),
])
b = tf.SparseTensor(list(b.keys()), list(b.values()), dense_shape=[2, 2, 4]) # `set_difference` is applied to each aligned pair of sets.
tf.sets.difference(a, b) # The result will be equivalent to either of:
#
# np.array([[{2}, {3}], [{}, {}]])
#
# collections.OrderedDict([
# ((0, 0, 0), 2),
# ((0, 1, 0), 3),
# ])
SparseTensor difference(IGraphNodeBase a, ValueTuple<IEnumerable<object>, object> b, bool aminusb, bool validate_indices)
Compute set difference of elements in last dimension of `a` and `b`. All but the last dimension of `a` and `b` must match. Example:
Parameters
-
IGraphNodeBasea - `Tensor` or `SparseTensor` of the same type as `b`. If sparse, indices must be sorted in row-major order.
-
ValueTuple<IEnumerable<object>, object>b - `Tensor` or `SparseTensor` of the same type as `a`. If sparse, indices must be sorted in row-major order.
-
boolaminusb - Whether to subtract `b` from `a`, vs vice versa.
-
boolvalidate_indices - Whether to validate the order and range of sparse indices in `a` and `b`.
Returns
-
SparseTensor - A `SparseTensor` whose shape is the same rank as `a` and `b`, and all but the last dimension the same. Elements along the last dimension contain the differences.
Show Example
import tensorflow as tf
import collections # Represent the following array of sets as a sparse tensor:
# a = np.array([[{1, 2}, {3}], [{4}, {5, 6}]])
a = collections.OrderedDict([
((0, 0, 0), 1),
((0, 0, 1), 2),
((0, 1, 0), 3),
((1, 0, 0), 4),
((1, 1, 0), 5),
((1, 1, 1), 6),
])
a = tf.SparseTensor(list(a.keys()), list(a.values()), dense_shape=[2, 2, 2]) # np.array([[{1, 3}, {2}], [{4, 5}, {5, 6, 7, 8}]])
b = collections.OrderedDict([
((0, 0, 0), 1),
((0, 0, 1), 3),
((0, 1, 0), 2),
((1, 0, 0), 4),
((1, 0, 1), 5),
((1, 1, 0), 5),
((1, 1, 1), 6),
((1, 1, 2), 7),
((1, 1, 3), 8),
])
b = tf.SparseTensor(list(b.keys()), list(b.values()), dense_shape=[2, 2, 4]) # `set_difference` is applied to each aligned pair of sets.
tf.sets.difference(a, b) # The result will be equivalent to either of:
#
# np.array([[{2}, {3}], [{}, {}]])
#
# collections.OrderedDict([
# ((0, 0, 0), 2),
# ((0, 1, 0), 3),
# ])
SparseTensor difference(IGraphNodeBase a, IGraphNodeBase b, bool aminusb, bool validate_indices)
Compute set difference of elements in last dimension of `a` and `b`. All but the last dimension of `a` and `b` must match. Example:
Parameters
-
IGraphNodeBasea - `Tensor` or `SparseTensor` of the same type as `b`. If sparse, indices must be sorted in row-major order.
-
IGraphNodeBaseb - `Tensor` or `SparseTensor` of the same type as `a`. If sparse, indices must be sorted in row-major order.
-
boolaminusb - Whether to subtract `b` from `a`, vs vice versa.
-
boolvalidate_indices - Whether to validate the order and range of sparse indices in `a` and `b`.
Returns
-
SparseTensor - A `SparseTensor` whose shape is the same rank as `a` and `b`, and all but the last dimension the same. Elements along the last dimension contain the differences.
Show Example
import tensorflow as tf
import collections # Represent the following array of sets as a sparse tensor:
# a = np.array([[{1, 2}, {3}], [{4}, {5, 6}]])
a = collections.OrderedDict([
((0, 0, 0), 1),
((0, 0, 1), 2),
((0, 1, 0), 3),
((1, 0, 0), 4),
((1, 1, 0), 5),
((1, 1, 1), 6),
])
a = tf.SparseTensor(list(a.keys()), list(a.values()), dense_shape=[2, 2, 2]) # np.array([[{1, 3}, {2}], [{4, 5}, {5, 6, 7, 8}]])
b = collections.OrderedDict([
((0, 0, 0), 1),
((0, 0, 1), 3),
((0, 1, 0), 2),
((1, 0, 0), 4),
((1, 0, 1), 5),
((1, 1, 0), 5),
((1, 1, 1), 6),
((1, 1, 2), 7),
((1, 1, 3), 8),
])
b = tf.SparseTensor(list(b.keys()), list(b.values()), dense_shape=[2, 2, 4]) # `set_difference` is applied to each aligned pair of sets.
tf.sets.difference(a, b) # The result will be equivalent to either of:
#
# np.array([[{2}, {3}], [{}, {}]])
#
# collections.OrderedDict([
# ((0, 0, 0), 2),
# ((0, 1, 0), 3),
# ])
object difference_dyn(object a, object b, ImplicitContainer<T> aminusb, ImplicitContainer<T> validate_indices)
Compute set difference of elements in last dimension of `a` and `b`. All but the last dimension of `a` and `b` must match. Example:
Parameters
-
objecta - `Tensor` or `SparseTensor` of the same type as `b`. If sparse, indices must be sorted in row-major order.
-
objectb - `Tensor` or `SparseTensor` of the same type as `a`. If sparse, indices must be sorted in row-major order.
-
ImplicitContainer<T>aminusb - Whether to subtract `b` from `a`, vs vice versa.
-
ImplicitContainer<T>validate_indices - Whether to validate the order and range of sparse indices in `a` and `b`.
Returns
-
object - A `SparseTensor` whose shape is the same rank as `a` and `b`, and all but the last dimension the same. Elements along the last dimension contain the differences.
Show Example
import tensorflow as tf
import collections # Represent the following array of sets as a sparse tensor:
# a = np.array([[{1, 2}, {3}], [{4}, {5, 6}]])
a = collections.OrderedDict([
((0, 0, 0), 1),
((0, 0, 1), 2),
((0, 1, 0), 3),
((1, 0, 0), 4),
((1, 1, 0), 5),
((1, 1, 1), 6),
])
a = tf.SparseTensor(list(a.keys()), list(a.values()), dense_shape=[2, 2, 2]) # np.array([[{1, 3}, {2}], [{4, 5}, {5, 6, 7, 8}]])
b = collections.OrderedDict([
((0, 0, 0), 1),
((0, 0, 1), 3),
((0, 1, 0), 2),
((1, 0, 0), 4),
((1, 0, 1), 5),
((1, 1, 0), 5),
((1, 1, 1), 6),
((1, 1, 2), 7),
((1, 1, 3), 8),
])
b = tf.SparseTensor(list(b.keys()), list(b.values()), dense_shape=[2, 2, 4]) # `set_difference` is applied to each aligned pair of sets.
tf.sets.difference(a, b) # The result will be equivalent to either of:
#
# np.array([[{2}, {3}], [{}, {}]])
#
# collections.OrderedDict([
# ((0, 0, 0), 2),
# ((0, 1, 0), 3),
# ])
SparseTensor intersection(IndexedSlices a, IGraphNodeBase b, bool validate_indices)
Compute set intersection of elements in last dimension of `a` and `b`. All but the last dimension of `a` and `b` must match. Example:
Parameters
-
IndexedSlicesa - `Tensor` or `SparseTensor` of the same type as `b`. If sparse, indices must be sorted in row-major order.
-
IGraphNodeBaseb - `Tensor` or `SparseTensor` of the same type as `a`. If sparse, indices must be sorted in row-major order.
-
boolvalidate_indices - Whether to validate the order and range of sparse indices in `a` and `b`.
Returns
-
SparseTensor - A `SparseTensor` whose shape is the same rank as `a` and `b`, and all but the last dimension the same. Elements along the last dimension contain the intersections.
Show Example
import tensorflow as tf
import collections # Represent the following array of sets as a sparse tensor:
# a = np.array([[{1, 2}, {3}], [{4}, {5, 6}]])
a = collections.OrderedDict([
((0, 0, 0), 1),
((0, 0, 1), 2),
((0, 1, 0), 3),
((1, 0, 0), 4),
((1, 1, 0), 5),
((1, 1, 1), 6),
])
a = tf.SparseTensor(list(a.keys()), list(a.values()), dense_shape=[2,2,2]) # b = np.array([[{1}, {}], [{4}, {5, 6, 7, 8}]])
b = collections.OrderedDict([
((0, 0, 0), 1),
((1, 0, 0), 4),
((1, 1, 0), 5),
((1, 1, 1), 6),
((1, 1, 2), 7),
((1, 1, 3), 8),
])
b = tf.SparseTensor(list(b.keys()), list(b.values()), dense_shape=[2, 2, 4]) # tf.sets.intersection is applied to each aligned pair of sets.
tf.sets.intersection(a, b) # The result will be equivalent to either of:
#
# np.array([[{1}, {}], [{4}, {5, 6}]])
#
# collections.OrderedDict([
# ((0, 0, 0), 1),
# ((1, 0, 0), 4),
# ((1, 1, 0), 5),
# ((1, 1, 1), 6),
# ])
SparseTensor intersection(ValueTuple<PythonClassContainer, PythonClassContainer> a, IEnumerable<object> b, bool validate_indices)
Compute set intersection of elements in last dimension of `a` and `b`. All but the last dimension of `a` and `b` must match. Example:
Parameters
-
ValueTuple<PythonClassContainer, PythonClassContainer>a - `Tensor` or `SparseTensor` of the same type as `b`. If sparse, indices must be sorted in row-major order.
-
IEnumerable<object>b - `Tensor` or `SparseTensor` of the same type as `a`. If sparse, indices must be sorted in row-major order.
-
boolvalidate_indices - Whether to validate the order and range of sparse indices in `a` and `b`.
Returns
-
SparseTensor - A `SparseTensor` whose shape is the same rank as `a` and `b`, and all but the last dimension the same. Elements along the last dimension contain the intersections.
Show Example
import tensorflow as tf
import collections # Represent the following array of sets as a sparse tensor:
# a = np.array([[{1, 2}, {3}], [{4}, {5, 6}]])
a = collections.OrderedDict([
((0, 0, 0), 1),
((0, 0, 1), 2),
((0, 1, 0), 3),
((1, 0, 0), 4),
((1, 1, 0), 5),
((1, 1, 1), 6),
])
a = tf.SparseTensor(list(a.keys()), list(a.values()), dense_shape=[2,2,2]) # b = np.array([[{1}, {}], [{4}, {5, 6, 7, 8}]])
b = collections.OrderedDict([
((0, 0, 0), 1),
((1, 0, 0), 4),
((1, 1, 0), 5),
((1, 1, 1), 6),
((1, 1, 2), 7),
((1, 1, 3), 8),
])
b = tf.SparseTensor(list(b.keys()), list(b.values()), dense_shape=[2, 2, 4]) # tf.sets.intersection is applied to each aligned pair of sets.
tf.sets.intersection(a, b) # The result will be equivalent to either of:
#
# np.array([[{1}, {}], [{4}, {5, 6}]])
#
# collections.OrderedDict([
# ((0, 0, 0), 1),
# ((1, 0, 0), 4),
# ((1, 1, 0), 5),
# ((1, 1, 1), 6),
# ])
SparseTensor intersection(ValueTuple<PythonClassContainer, PythonClassContainer> a, ValueTuple<PythonClassContainer, PythonClassContainer> b, bool validate_indices)
Compute set intersection of elements in last dimension of `a` and `b`. All but the last dimension of `a` and `b` must match. Example:
Parameters
-
ValueTuple<PythonClassContainer, PythonClassContainer>a - `Tensor` or `SparseTensor` of the same type as `b`. If sparse, indices must be sorted in row-major order.
-
ValueTuple<PythonClassContainer, PythonClassContainer>b - `Tensor` or `SparseTensor` of the same type as `a`. If sparse, indices must be sorted in row-major order.
-
boolvalidate_indices - Whether to validate the order and range of sparse indices in `a` and `b`.
Returns
-
SparseTensor - A `SparseTensor` whose shape is the same rank as `a` and `b`, and all but the last dimension the same. Elements along the last dimension contain the intersections.
Show Example
import tensorflow as tf
import collections # Represent the following array of sets as a sparse tensor:
# a = np.array([[{1, 2}, {3}], [{4}, {5, 6}]])
a = collections.OrderedDict([
((0, 0, 0), 1),
((0, 0, 1), 2),
((0, 1, 0), 3),
((1, 0, 0), 4),
((1, 1, 0), 5),
((1, 1, 1), 6),
])
a = tf.SparseTensor(list(a.keys()), list(a.values()), dense_shape=[2,2,2]) # b = np.array([[{1}, {}], [{4}, {5, 6, 7, 8}]])
b = collections.OrderedDict([
((0, 0, 0), 1),
((1, 0, 0), 4),
((1, 1, 0), 5),
((1, 1, 1), 6),
((1, 1, 2), 7),
((1, 1, 3), 8),
])
b = tf.SparseTensor(list(b.keys()), list(b.values()), dense_shape=[2, 2, 4]) # tf.sets.intersection is applied to each aligned pair of sets.
tf.sets.intersection(a, b) # The result will be equivalent to either of:
#
# np.array([[{1}, {}], [{4}, {5, 6}]])
#
# collections.OrderedDict([
# ((0, 0, 0), 1),
# ((1, 0, 0), 4),
# ((1, 1, 0), 5),
# ((1, 1, 1), 6),
# ])
SparseTensor intersection(ValueTuple<PythonClassContainer, PythonClassContainer> a, IndexedSlices b, bool validate_indices)
Compute set intersection of elements in last dimension of `a` and `b`. All but the last dimension of `a` and `b` must match. Example:
Parameters
-
ValueTuple<PythonClassContainer, PythonClassContainer>a - `Tensor` or `SparseTensor` of the same type as `b`. If sparse, indices must be sorted in row-major order.
-
IndexedSlicesb - `Tensor` or `SparseTensor` of the same type as `a`. If sparse, indices must be sorted in row-major order.
-
boolvalidate_indices - Whether to validate the order and range of sparse indices in `a` and `b`.
Returns
-
SparseTensor - A `SparseTensor` whose shape is the same rank as `a` and `b`, and all but the last dimension the same. Elements along the last dimension contain the intersections.
Show Example
import tensorflow as tf
import collections # Represent the following array of sets as a sparse tensor:
# a = np.array([[{1, 2}, {3}], [{4}, {5, 6}]])
a = collections.OrderedDict([
((0, 0, 0), 1),
((0, 0, 1), 2),
((0, 1, 0), 3),
((1, 0, 0), 4),
((1, 1, 0), 5),
((1, 1, 1), 6),
])
a = tf.SparseTensor(list(a.keys()), list(a.values()), dense_shape=[2,2,2]) # b = np.array([[{1}, {}], [{4}, {5, 6, 7, 8}]])
b = collections.OrderedDict([
((0, 0, 0), 1),
((1, 0, 0), 4),
((1, 1, 0), 5),
((1, 1, 1), 6),
((1, 1, 2), 7),
((1, 1, 3), 8),
])
b = tf.SparseTensor(list(b.keys()), list(b.values()), dense_shape=[2, 2, 4]) # tf.sets.intersection is applied to each aligned pair of sets.
tf.sets.intersection(a, b) # The result will be equivalent to either of:
#
# np.array([[{1}, {}], [{4}, {5, 6}]])
#
# collections.OrderedDict([
# ((0, 0, 0), 1),
# ((1, 0, 0), 4),
# ((1, 1, 0), 5),
# ((1, 1, 1), 6),
# ])
SparseTensor intersection(ValueTuple<PythonClassContainer, PythonClassContainer> a, IGraphNodeBase b, bool validate_indices)
Compute set intersection of elements in last dimension of `a` and `b`. All but the last dimension of `a` and `b` must match. Example:
Parameters
-
ValueTuple<PythonClassContainer, PythonClassContainer>a - `Tensor` or `SparseTensor` of the same type as `b`. If sparse, indices must be sorted in row-major order.
-
IGraphNodeBaseb - `Tensor` or `SparseTensor` of the same type as `a`. If sparse, indices must be sorted in row-major order.
-
boolvalidate_indices - Whether to validate the order and range of sparse indices in `a` and `b`.
Returns
-
SparseTensor - A `SparseTensor` whose shape is the same rank as `a` and `b`, and all but the last dimension the same. Elements along the last dimension contain the intersections.
Show Example
import tensorflow as tf
import collections # Represent the following array of sets as a sparse tensor:
# a = np.array([[{1, 2}, {3}], [{4}, {5, 6}]])
a = collections.OrderedDict([
((0, 0, 0), 1),
((0, 0, 1), 2),
((0, 1, 0), 3),
((1, 0, 0), 4),
((1, 1, 0), 5),
((1, 1, 1), 6),
])
a = tf.SparseTensor(list(a.keys()), list(a.values()), dense_shape=[2,2,2]) # b = np.array([[{1}, {}], [{4}, {5, 6, 7, 8}]])
b = collections.OrderedDict([
((0, 0, 0), 1),
((1, 0, 0), 4),
((1, 1, 0), 5),
((1, 1, 1), 6),
((1, 1, 2), 7),
((1, 1, 3), 8),
])
b = tf.SparseTensor(list(b.keys()), list(b.values()), dense_shape=[2, 2, 4]) # tf.sets.intersection is applied to each aligned pair of sets.
tf.sets.intersection(a, b) # The result will be equivalent to either of:
#
# np.array([[{1}, {}], [{4}, {5, 6}]])
#
# collections.OrderedDict([
# ((0, 0, 0), 1),
# ((1, 0, 0), 4),
# ((1, 1, 0), 5),
# ((1, 1, 1), 6),
# ])
SparseTensor intersection(ValueTuple<PythonClassContainer, PythonClassContainer> a, object b, bool validate_indices)
Compute set intersection of elements in last dimension of `a` and `b`. All but the last dimension of `a` and `b` must match. Example:
Parameters
-
ValueTuple<PythonClassContainer, PythonClassContainer>a - `Tensor` or `SparseTensor` of the same type as `b`. If sparse, indices must be sorted in row-major order.
-
objectb - `Tensor` or `SparseTensor` of the same type as `a`. If sparse, indices must be sorted in row-major order.
-
boolvalidate_indices - Whether to validate the order and range of sparse indices in `a` and `b`.
Returns
-
SparseTensor - A `SparseTensor` whose shape is the same rank as `a` and `b`, and all but the last dimension the same. Elements along the last dimension contain the intersections.
Show Example
import tensorflow as tf
import collections # Represent the following array of sets as a sparse tensor:
# a = np.array([[{1, 2}, {3}], [{4}, {5, 6}]])
a = collections.OrderedDict([
((0, 0, 0), 1),
((0, 0, 1), 2),
((0, 1, 0), 3),
((1, 0, 0), 4),
((1, 1, 0), 5),
((1, 1, 1), 6),
])
a = tf.SparseTensor(list(a.keys()), list(a.values()), dense_shape=[2,2,2]) # b = np.array([[{1}, {}], [{4}, {5, 6, 7, 8}]])
b = collections.OrderedDict([
((0, 0, 0), 1),
((1, 0, 0), 4),
((1, 1, 0), 5),
((1, 1, 1), 6),
((1, 1, 2), 7),
((1, 1, 3), 8),
])
b = tf.SparseTensor(list(b.keys()), list(b.values()), dense_shape=[2, 2, 4]) # tf.sets.intersection is applied to each aligned pair of sets.
tf.sets.intersection(a, b) # The result will be equivalent to either of:
#
# np.array([[{1}, {}], [{4}, {5, 6}]])
#
# collections.OrderedDict([
# ((0, 0, 0), 1),
# ((1, 0, 0), 4),
# ((1, 1, 0), 5),
# ((1, 1, 1), 6),
# ])
SparseTensor intersection(IndexedSlices a, ndarray b, bool validate_indices)
Compute set intersection of elements in last dimension of `a` and `b`. All but the last dimension of `a` and `b` must match. Example:
Parameters
-
IndexedSlicesa - `Tensor` or `SparseTensor` of the same type as `b`. If sparse, indices must be sorted in row-major order.
-
ndarrayb - `Tensor` or `SparseTensor` of the same type as `a`. If sparse, indices must be sorted in row-major order.
-
boolvalidate_indices - Whether to validate the order and range of sparse indices in `a` and `b`.
Returns
-
SparseTensor - A `SparseTensor` whose shape is the same rank as `a` and `b`, and all but the last dimension the same. Elements along the last dimension contain the intersections.
Show Example
import tensorflow as tf
import collections # Represent the following array of sets as a sparse tensor:
# a = np.array([[{1, 2}, {3}], [{4}, {5, 6}]])
a = collections.OrderedDict([
((0, 0, 0), 1),
((0, 0, 1), 2),
((0, 1, 0), 3),
((1, 0, 0), 4),
((1, 1, 0), 5),
((1, 1, 1), 6),
])
a = tf.SparseTensor(list(a.keys()), list(a.values()), dense_shape=[2,2,2]) # b = np.array([[{1}, {}], [{4}, {5, 6, 7, 8}]])
b = collections.OrderedDict([
((0, 0, 0), 1),
((1, 0, 0), 4),
((1, 1, 0), 5),
((1, 1, 1), 6),
((1, 1, 2), 7),
((1, 1, 3), 8),
])
b = tf.SparseTensor(list(b.keys()), list(b.values()), dense_shape=[2, 2, 4]) # tf.sets.intersection is applied to each aligned pair of sets.
tf.sets.intersection(a, b) # The result will be equivalent to either of:
#
# np.array([[{1}, {}], [{4}, {5, 6}]])
#
# collections.OrderedDict([
# ((0, 0, 0), 1),
# ((1, 0, 0), 4),
# ((1, 1, 0), 5),
# ((1, 1, 1), 6),
# ])
SparseTensor intersection(IndexedSlices a, IEnumerable<object> b, bool validate_indices)
Compute set intersection of elements in last dimension of `a` and `b`. All but the last dimension of `a` and `b` must match. Example:
Parameters
-
IndexedSlicesa - `Tensor` or `SparseTensor` of the same type as `b`. If sparse, indices must be sorted in row-major order.
-
IEnumerable<object>b - `Tensor` or `SparseTensor` of the same type as `a`. If sparse, indices must be sorted in row-major order.
-
boolvalidate_indices - Whether to validate the order and range of sparse indices in `a` and `b`.
Returns
-
SparseTensor - A `SparseTensor` whose shape is the same rank as `a` and `b`, and all but the last dimension the same. Elements along the last dimension contain the intersections.
Show Example
import tensorflow as tf
import collections # Represent the following array of sets as a sparse tensor:
# a = np.array([[{1, 2}, {3}], [{4}, {5, 6}]])
a = collections.OrderedDict([
((0, 0, 0), 1),
((0, 0, 1), 2),
((0, 1, 0), 3),
((1, 0, 0), 4),
((1, 1, 0), 5),
((1, 1, 1), 6),
])
a = tf.SparseTensor(list(a.keys()), list(a.values()), dense_shape=[2,2,2]) # b = np.array([[{1}, {}], [{4}, {5, 6, 7, 8}]])
b = collections.OrderedDict([
((0, 0, 0), 1),
((1, 0, 0), 4),
((1, 1, 0), 5),
((1, 1, 1), 6),
((1, 1, 2), 7),
((1, 1, 3), 8),
])
b = tf.SparseTensor(list(b.keys()), list(b.values()), dense_shape=[2, 2, 4]) # tf.sets.intersection is applied to each aligned pair of sets.
tf.sets.intersection(a, b) # The result will be equivalent to either of:
#
# np.array([[{1}, {}], [{4}, {5, 6}]])
#
# collections.OrderedDict([
# ((0, 0, 0), 1),
# ((1, 0, 0), 4),
# ((1, 1, 0), 5),
# ((1, 1, 1), 6),
# ])
SparseTensor intersection(IndexedSlices a, IndexedSlices b, bool validate_indices)
Compute set intersection of elements in last dimension of `a` and `b`. All but the last dimension of `a` and `b` must match. Example:
Parameters
-
IndexedSlicesa - `Tensor` or `SparseTensor` of the same type as `b`. If sparse, indices must be sorted in row-major order.
-
IndexedSlicesb - `Tensor` or `SparseTensor` of the same type as `a`. If sparse, indices must be sorted in row-major order.
-
boolvalidate_indices - Whether to validate the order and range of sparse indices in `a` and `b`.
Returns
-
SparseTensor - A `SparseTensor` whose shape is the same rank as `a` and `b`, and all but the last dimension the same. Elements along the last dimension contain the intersections.
Show Example
import tensorflow as tf
import collections # Represent the following array of sets as a sparse tensor:
# a = np.array([[{1, 2}, {3}], [{4}, {5, 6}]])
a = collections.OrderedDict([
((0, 0, 0), 1),
((0, 0, 1), 2),
((0, 1, 0), 3),
((1, 0, 0), 4),
((1, 1, 0), 5),
((1, 1, 1), 6),
])
a = tf.SparseTensor(list(a.keys()), list(a.values()), dense_shape=[2,2,2]) # b = np.array([[{1}, {}], [{4}, {5, 6, 7, 8}]])
b = collections.OrderedDict([
((0, 0, 0), 1),
((1, 0, 0), 4),
((1, 1, 0), 5),
((1, 1, 1), 6),
((1, 1, 2), 7),
((1, 1, 3), 8),
])
b = tf.SparseTensor(list(b.keys()), list(b.values()), dense_shape=[2, 2, 4]) # tf.sets.intersection is applied to each aligned pair of sets.
tf.sets.intersection(a, b) # The result will be equivalent to either of:
#
# np.array([[{1}, {}], [{4}, {5, 6}]])
#
# collections.OrderedDict([
# ((0, 0, 0), 1),
# ((1, 0, 0), 4),
# ((1, 1, 0), 5),
# ((1, 1, 1), 6),
# ])
SparseTensor intersection(IndexedSlices a, ValueTuple<PythonClassContainer, PythonClassContainer> b, bool validate_indices)
Compute set intersection of elements in last dimension of `a` and `b`. All but the last dimension of `a` and `b` must match. Example:
Parameters
-
IndexedSlicesa - `Tensor` or `SparseTensor` of the same type as `b`. If sparse, indices must be sorted in row-major order.
-
ValueTuple<PythonClassContainer, PythonClassContainer>b - `Tensor` or `SparseTensor` of the same type as `a`. If sparse, indices must be sorted in row-major order.
-
boolvalidate_indices - Whether to validate the order and range of sparse indices in `a` and `b`.
Returns
-
SparseTensor - A `SparseTensor` whose shape is the same rank as `a` and `b`, and all but the last dimension the same. Elements along the last dimension contain the intersections.
Show Example
import tensorflow as tf
import collections # Represent the following array of sets as a sparse tensor:
# a = np.array([[{1, 2}, {3}], [{4}, {5, 6}]])
a = collections.OrderedDict([
((0, 0, 0), 1),
((0, 0, 1), 2),
((0, 1, 0), 3),
((1, 0, 0), 4),
((1, 1, 0), 5),
((1, 1, 1), 6),
])
a = tf.SparseTensor(list(a.keys()), list(a.values()), dense_shape=[2,2,2]) # b = np.array([[{1}, {}], [{4}, {5, 6, 7, 8}]])
b = collections.OrderedDict([
((0, 0, 0), 1),
((1, 0, 0), 4),
((1, 1, 0), 5),
((1, 1, 1), 6),
((1, 1, 2), 7),
((1, 1, 3), 8),
])
b = tf.SparseTensor(list(b.keys()), list(b.values()), dense_shape=[2, 2, 4]) # tf.sets.intersection is applied to each aligned pair of sets.
tf.sets.intersection(a, b) # The result will be equivalent to either of:
#
# np.array([[{1}, {}], [{4}, {5, 6}]])
#
# collections.OrderedDict([
# ((0, 0, 0), 1),
# ((1, 0, 0), 4),
# ((1, 1, 0), 5),
# ((1, 1, 1), 6),
# ])
SparseTensor intersection(IGraphNodeBase a, object b, bool validate_indices)
Compute set intersection of elements in last dimension of `a` and `b`. All but the last dimension of `a` and `b` must match. Example:
Parameters
-
IGraphNodeBasea - `Tensor` or `SparseTensor` of the same type as `b`. If sparse, indices must be sorted in row-major order.
-
objectb - `Tensor` or `SparseTensor` of the same type as `a`. If sparse, indices must be sorted in row-major order.
-
boolvalidate_indices - Whether to validate the order and range of sparse indices in `a` and `b`.
Returns
-
SparseTensor - A `SparseTensor` whose shape is the same rank as `a` and `b`, and all but the last dimension the same. Elements along the last dimension contain the intersections.
Show Example
import tensorflow as tf
import collections # Represent the following array of sets as a sparse tensor:
# a = np.array([[{1, 2}, {3}], [{4}, {5, 6}]])
a = collections.OrderedDict([
((0, 0, 0), 1),
((0, 0, 1), 2),
((0, 1, 0), 3),
((1, 0, 0), 4),
((1, 1, 0), 5),
((1, 1, 1), 6),
])
a = tf.SparseTensor(list(a.keys()), list(a.values()), dense_shape=[2,2,2]) # b = np.array([[{1}, {}], [{4}, {5, 6, 7, 8}]])
b = collections.OrderedDict([
((0, 0, 0), 1),
((1, 0, 0), 4),
((1, 1, 0), 5),
((1, 1, 1), 6),
((1, 1, 2), 7),
((1, 1, 3), 8),
])
b = tf.SparseTensor(list(b.keys()), list(b.values()), dense_shape=[2, 2, 4]) # tf.sets.intersection is applied to each aligned pair of sets.
tf.sets.intersection(a, b) # The result will be equivalent to either of:
#
# np.array([[{1}, {}], [{4}, {5, 6}]])
#
# collections.OrderedDict([
# ((0, 0, 0), 1),
# ((1, 0, 0), 4),
# ((1, 1, 0), 5),
# ((1, 1, 1), 6),
# ])
SparseTensor intersection(IGraphNodeBase a, IGraphNodeBase b, bool validate_indices)
Compute set intersection of elements in last dimension of `a` and `b`. All but the last dimension of `a` and `b` must match. Example:
Parameters
-
IGraphNodeBasea - `Tensor` or `SparseTensor` of the same type as `b`. If sparse, indices must be sorted in row-major order.
-
IGraphNodeBaseb - `Tensor` or `SparseTensor` of the same type as `a`. If sparse, indices must be sorted in row-major order.
-
boolvalidate_indices - Whether to validate the order and range of sparse indices in `a` and `b`.
Returns
-
SparseTensor - A `SparseTensor` whose shape is the same rank as `a` and `b`, and all but the last dimension the same. Elements along the last dimension contain the intersections.
Show Example
import tensorflow as tf
import collections # Represent the following array of sets as a sparse tensor:
# a = np.array([[{1, 2}, {3}], [{4}, {5, 6}]])
a = collections.OrderedDict([
((0, 0, 0), 1),
((0, 0, 1), 2),
((0, 1, 0), 3),
((1, 0, 0), 4),
((1, 1, 0), 5),
((1, 1, 1), 6),
])
a = tf.SparseTensor(list(a.keys()), list(a.values()), dense_shape=[2,2,2]) # b = np.array([[{1}, {}], [{4}, {5, 6, 7, 8}]])
b = collections.OrderedDict([
((0, 0, 0), 1),
((1, 0, 0), 4),
((1, 1, 0), 5),
((1, 1, 1), 6),
((1, 1, 2), 7),
((1, 1, 3), 8),
])
b = tf.SparseTensor(list(b.keys()), list(b.values()), dense_shape=[2, 2, 4]) # tf.sets.intersection is applied to each aligned pair of sets.
tf.sets.intersection(a, b) # The result will be equivalent to either of:
#
# np.array([[{1}, {}], [{4}, {5, 6}]])
#
# collections.OrderedDict([
# ((0, 0, 0), 1),
# ((1, 0, 0), 4),
# ((1, 1, 0), 5),
# ((1, 1, 1), 6),
# ])
SparseTensor intersection(IGraphNodeBase a, IndexedSlices b, bool validate_indices)
Compute set intersection of elements in last dimension of `a` and `b`. All but the last dimension of `a` and `b` must match. Example:
Parameters
-
IGraphNodeBasea - `Tensor` or `SparseTensor` of the same type as `b`. If sparse, indices must be sorted in row-major order.
-
IndexedSlicesb - `Tensor` or `SparseTensor` of the same type as `a`. If sparse, indices must be sorted in row-major order.
-
boolvalidate_indices - Whether to validate the order and range of sparse indices in `a` and `b`.
Returns
-
SparseTensor - A `SparseTensor` whose shape is the same rank as `a` and `b`, and all but the last dimension the same. Elements along the last dimension contain the intersections.
Show Example
import tensorflow as tf
import collections # Represent the following array of sets as a sparse tensor:
# a = np.array([[{1, 2}, {3}], [{4}, {5, 6}]])
a = collections.OrderedDict([
((0, 0, 0), 1),
((0, 0, 1), 2),
((0, 1, 0), 3),
((1, 0, 0), 4),
((1, 1, 0), 5),
((1, 1, 1), 6),
])
a = tf.SparseTensor(list(a.keys()), list(a.values()), dense_shape=[2,2,2]) # b = np.array([[{1}, {}], [{4}, {5, 6, 7, 8}]])
b = collections.OrderedDict([
((0, 0, 0), 1),
((1, 0, 0), 4),
((1, 1, 0), 5),
((1, 1, 1), 6),
((1, 1, 2), 7),
((1, 1, 3), 8),
])
b = tf.SparseTensor(list(b.keys()), list(b.values()), dense_shape=[2, 2, 4]) # tf.sets.intersection is applied to each aligned pair of sets.
tf.sets.intersection(a, b) # The result will be equivalent to either of:
#
# np.array([[{1}, {}], [{4}, {5, 6}]])
#
# collections.OrderedDict([
# ((0, 0, 0), 1),
# ((1, 0, 0), 4),
# ((1, 1, 0), 5),
# ((1, 1, 1), 6),
# ])
SparseTensor intersection(IGraphNodeBase a, ValueTuple<PythonClassContainer, PythonClassContainer> b, bool validate_indices)
Compute set intersection of elements in last dimension of `a` and `b`. All but the last dimension of `a` and `b` must match. Example:
Parameters
-
IGraphNodeBasea - `Tensor` or `SparseTensor` of the same type as `b`. If sparse, indices must be sorted in row-major order.
-
ValueTuple<PythonClassContainer, PythonClassContainer>b - `Tensor` or `SparseTensor` of the same type as `a`. If sparse, indices must be sorted in row-major order.
-
boolvalidate_indices - Whether to validate the order and range of sparse indices in `a` and `b`.
Returns
-
SparseTensor - A `SparseTensor` whose shape is the same rank as `a` and `b`, and all but the last dimension the same. Elements along the last dimension contain the intersections.
Show Example
import tensorflow as tf
import collections # Represent the following array of sets as a sparse tensor:
# a = np.array([[{1, 2}, {3}], [{4}, {5, 6}]])
a = collections.OrderedDict([
((0, 0, 0), 1),
((0, 0, 1), 2),
((0, 1, 0), 3),
((1, 0, 0), 4),
((1, 1, 0), 5),
((1, 1, 1), 6),
])
a = tf.SparseTensor(list(a.keys()), list(a.values()), dense_shape=[2,2,2]) # b = np.array([[{1}, {}], [{4}, {5, 6, 7, 8}]])
b = collections.OrderedDict([
((0, 0, 0), 1),
((1, 0, 0), 4),
((1, 1, 0), 5),
((1, 1, 1), 6),
((1, 1, 2), 7),
((1, 1, 3), 8),
])
b = tf.SparseTensor(list(b.keys()), list(b.values()), dense_shape=[2, 2, 4]) # tf.sets.intersection is applied to each aligned pair of sets.
tf.sets.intersection(a, b) # The result will be equivalent to either of:
#
# np.array([[{1}, {}], [{4}, {5, 6}]])
#
# collections.OrderedDict([
# ((0, 0, 0), 1),
# ((1, 0, 0), 4),
# ((1, 1, 0), 5),
# ((1, 1, 1), 6),
# ])
SparseTensor intersection(IGraphNodeBase a, ndarray b, bool validate_indices)
Compute set intersection of elements in last dimension of `a` and `b`. All but the last dimension of `a` and `b` must match. Example:
Parameters
-
IGraphNodeBasea - `Tensor` or `SparseTensor` of the same type as `b`. If sparse, indices must be sorted in row-major order.
-
ndarrayb - `Tensor` or `SparseTensor` of the same type as `a`. If sparse, indices must be sorted in row-major order.
-
boolvalidate_indices - Whether to validate the order and range of sparse indices in `a` and `b`.
Returns
-
SparseTensor - A `SparseTensor` whose shape is the same rank as `a` and `b`, and all but the last dimension the same. Elements along the last dimension contain the intersections.
Show Example
import tensorflow as tf
import collections # Represent the following array of sets as a sparse tensor:
# a = np.array([[{1, 2}, {3}], [{4}, {5, 6}]])
a = collections.OrderedDict([
((0, 0, 0), 1),
((0, 0, 1), 2),
((0, 1, 0), 3),
((1, 0, 0), 4),
((1, 1, 0), 5),
((1, 1, 1), 6),
])
a = tf.SparseTensor(list(a.keys()), list(a.values()), dense_shape=[2,2,2]) # b = np.array([[{1}, {}], [{4}, {5, 6, 7, 8}]])
b = collections.OrderedDict([
((0, 0, 0), 1),
((1, 0, 0), 4),
((1, 1, 0), 5),
((1, 1, 1), 6),
((1, 1, 2), 7),
((1, 1, 3), 8),
])
b = tf.SparseTensor(list(b.keys()), list(b.values()), dense_shape=[2, 2, 4]) # tf.sets.intersection is applied to each aligned pair of sets.
tf.sets.intersection(a, b) # The result will be equivalent to either of:
#
# np.array([[{1}, {}], [{4}, {5, 6}]])
#
# collections.OrderedDict([
# ((0, 0, 0), 1),
# ((1, 0, 0), 4),
# ((1, 1, 0), 5),
# ((1, 1, 1), 6),
# ])
SparseTensor intersection(IndexedSlices a, object b, bool validate_indices)
Compute set intersection of elements in last dimension of `a` and `b`. All but the last dimension of `a` and `b` must match. Example:
Parameters
-
IndexedSlicesa - `Tensor` or `SparseTensor` of the same type as `b`. If sparse, indices must be sorted in row-major order.
-
objectb - `Tensor` or `SparseTensor` of the same type as `a`. If sparse, indices must be sorted in row-major order.
-
boolvalidate_indices - Whether to validate the order and range of sparse indices in `a` and `b`.
Returns
-
SparseTensor - A `SparseTensor` whose shape is the same rank as `a` and `b`, and all but the last dimension the same. Elements along the last dimension contain the intersections.
Show Example
import tensorflow as tf
import collections # Represent the following array of sets as a sparse tensor:
# a = np.array([[{1, 2}, {3}], [{4}, {5, 6}]])
a = collections.OrderedDict([
((0, 0, 0), 1),
((0, 0, 1), 2),
((0, 1, 0), 3),
((1, 0, 0), 4),
((1, 1, 0), 5),
((1, 1, 1), 6),
])
a = tf.SparseTensor(list(a.keys()), list(a.values()), dense_shape=[2,2,2]) # b = np.array([[{1}, {}], [{4}, {5, 6, 7, 8}]])
b = collections.OrderedDict([
((0, 0, 0), 1),
((1, 0, 0), 4),
((1, 1, 0), 5),
((1, 1, 1), 6),
((1, 1, 2), 7),
((1, 1, 3), 8),
])
b = tf.SparseTensor(list(b.keys()), list(b.values()), dense_shape=[2, 2, 4]) # tf.sets.intersection is applied to each aligned pair of sets.
tf.sets.intersection(a, b) # The result will be equivalent to either of:
#
# np.array([[{1}, {}], [{4}, {5, 6}]])
#
# collections.OrderedDict([
# ((0, 0, 0), 1),
# ((1, 0, 0), 4),
# ((1, 1, 0), 5),
# ((1, 1, 1), 6),
# ])
SparseTensor intersection(ValueTuple<PythonClassContainer, PythonClassContainer> a, ndarray b, bool validate_indices)
Compute set intersection of elements in last dimension of `a` and `b`. All but the last dimension of `a` and `b` must match. Example:
Parameters
-
ValueTuple<PythonClassContainer, PythonClassContainer>a - `Tensor` or `SparseTensor` of the same type as `b`. If sparse, indices must be sorted in row-major order.
-
ndarrayb - `Tensor` or `SparseTensor` of the same type as `a`. If sparse, indices must be sorted in row-major order.
-
boolvalidate_indices - Whether to validate the order and range of sparse indices in `a` and `b`.
Returns
-
SparseTensor - A `SparseTensor` whose shape is the same rank as `a` and `b`, and all but the last dimension the same. Elements along the last dimension contain the intersections.
Show Example
import tensorflow as tf
import collections # Represent the following array of sets as a sparse tensor:
# a = np.array([[{1, 2}, {3}], [{4}, {5, 6}]])
a = collections.OrderedDict([
((0, 0, 0), 1),
((0, 0, 1), 2),
((0, 1, 0), 3),
((1, 0, 0), 4),
((1, 1, 0), 5),
((1, 1, 1), 6),
])
a = tf.SparseTensor(list(a.keys()), list(a.values()), dense_shape=[2,2,2]) # b = np.array([[{1}, {}], [{4}, {5, 6, 7, 8}]])
b = collections.OrderedDict([
((0, 0, 0), 1),
((1, 0, 0), 4),
((1, 1, 0), 5),
((1, 1, 1), 6),
((1, 1, 2), 7),
((1, 1, 3), 8),
])
b = tf.SparseTensor(list(b.keys()), list(b.values()), dense_shape=[2, 2, 4]) # tf.sets.intersection is applied to each aligned pair of sets.
tf.sets.intersection(a, b) # The result will be equivalent to either of:
#
# np.array([[{1}, {}], [{4}, {5, 6}]])
#
# collections.OrderedDict([
# ((0, 0, 0), 1),
# ((1, 0, 0), 4),
# ((1, 1, 0), 5),
# ((1, 1, 1), 6),
# ])
SparseTensor intersection(IGraphNodeBase a, IEnumerable<object> b, bool validate_indices)
Compute set intersection of elements in last dimension of `a` and `b`. All but the last dimension of `a` and `b` must match. Example:
Parameters
-
IGraphNodeBasea - `Tensor` or `SparseTensor` of the same type as `b`. If sparse, indices must be sorted in row-major order.
-
IEnumerable<object>b - `Tensor` or `SparseTensor` of the same type as `a`. If sparse, indices must be sorted in row-major order.
-
boolvalidate_indices - Whether to validate the order and range of sparse indices in `a` and `b`.
Returns
-
SparseTensor - A `SparseTensor` whose shape is the same rank as `a` and `b`, and all but the last dimension the same. Elements along the last dimension contain the intersections.
Show Example
import tensorflow as tf
import collections # Represent the following array of sets as a sparse tensor:
# a = np.array([[{1, 2}, {3}], [{4}, {5, 6}]])
a = collections.OrderedDict([
((0, 0, 0), 1),
((0, 0, 1), 2),
((0, 1, 0), 3),
((1, 0, 0), 4),
((1, 1, 0), 5),
((1, 1, 1), 6),
])
a = tf.SparseTensor(list(a.keys()), list(a.values()), dense_shape=[2,2,2]) # b = np.array([[{1}, {}], [{4}, {5, 6, 7, 8}]])
b = collections.OrderedDict([
((0, 0, 0), 1),
((1, 0, 0), 4),
((1, 1, 0), 5),
((1, 1, 1), 6),
((1, 1, 2), 7),
((1, 1, 3), 8),
])
b = tf.SparseTensor(list(b.keys()), list(b.values()), dense_shape=[2, 2, 4]) # tf.sets.intersection is applied to each aligned pair of sets.
tf.sets.intersection(a, b) # The result will be equivalent to either of:
#
# np.array([[{1}, {}], [{4}, {5, 6}]])
#
# collections.OrderedDict([
# ((0, 0, 0), 1),
# ((1, 0, 0), 4),
# ((1, 1, 0), 5),
# ((1, 1, 1), 6),
# ])
object intersection_dyn(object a, object b, ImplicitContainer<T> validate_indices)
Compute set intersection of elements in last dimension of `a` and `b`. All but the last dimension of `a` and `b` must match. Example:
Parameters
-
objecta - `Tensor` or `SparseTensor` of the same type as `b`. If sparse, indices must be sorted in row-major order.
-
objectb - `Tensor` or `SparseTensor` of the same type as `a`. If sparse, indices must be sorted in row-major order.
-
ImplicitContainer<T>validate_indices - Whether to validate the order and range of sparse indices in `a` and `b`.
Returns
-
object - A `SparseTensor` whose shape is the same rank as `a` and `b`, and all but the last dimension the same. Elements along the last dimension contain the intersections.
Show Example
import tensorflow as tf
import collections # Represent the following array of sets as a sparse tensor:
# a = np.array([[{1, 2}, {3}], [{4}, {5, 6}]])
a = collections.OrderedDict([
((0, 0, 0), 1),
((0, 0, 1), 2),
((0, 1, 0), 3),
((1, 0, 0), 4),
((1, 1, 0), 5),
((1, 1, 1), 6),
])
a = tf.SparseTensor(list(a.keys()), list(a.values()), dense_shape=[2,2,2]) # b = np.array([[{1}, {}], [{4}, {5, 6, 7, 8}]])
b = collections.OrderedDict([
((0, 0, 0), 1),
((1, 0, 0), 4),
((1, 1, 0), 5),
((1, 1, 1), 6),
((1, 1, 2), 7),
((1, 1, 3), 8),
])
b = tf.SparseTensor(list(b.keys()), list(b.values()), dense_shape=[2, 2, 4]) # tf.sets.intersection is applied to each aligned pair of sets.
tf.sets.intersection(a, b) # The result will be equivalent to either of:
#
# np.array([[{1}, {}], [{4}, {5, 6}]])
#
# collections.OrderedDict([
# ((0, 0, 0), 1),
# ((1, 0, 0), 4),
# ((1, 1, 0), 5),
# ((1, 1, 1), 6),
# ])
Tensor size(SparseTensor a, bool validate_indices)
Compute number of unique elements along last dimension of `a`.
Parameters
-
SparseTensora - `SparseTensor`, with indices sorted in row-major order.
-
boolvalidate_indices - Whether to validate the order and range of sparse indices in `a`.
Returns
-
Tensor - `int32` `Tensor` of set sizes. For `a` ranked `n`, this is a `Tensor` with rank `n-1`, and the same 1st `n-1` dimensions as `a`. Each value is the number of unique elements in the corresponding `[0...n-1]` dimension of `a`.
object size_dyn(object a, ImplicitContainer<T> validate_indices)
Compute number of unique elements along last dimension of `a`.
Parameters
-
objecta - `SparseTensor`, with indices sorted in row-major order.
-
ImplicitContainer<T>validate_indices - Whether to validate the order and range of sparse indices in `a`.
Returns
-
object - `int32` `Tensor` of set sizes. For `a` ranked `n`, this is a `Tensor` with rank `n-1`, and the same 1st `n-1` dimensions as `a`. Each value is the number of unique elements in the corresponding `[0...n-1]` dimension of `a`.
SparseTensor union(IGraphNodeBase a, IGraphNodeBase b, bool validate_indices)
Compute set union of elements in last dimension of `a` and `b`. All but the last dimension of `a` and `b` must match. Example:
Parameters
-
IGraphNodeBasea - `Tensor` or `SparseTensor` of the same type as `b`. If sparse, indices must be sorted in row-major order.
-
IGraphNodeBaseb - `Tensor` or `SparseTensor` of the same type as `a`. If sparse, indices must be sorted in row-major order.
-
boolvalidate_indices - Whether to validate the order and range of sparse indices in `a` and `b`.
Returns
-
SparseTensor - A `SparseTensor` whose shape is the same rank as `a` and `b`, and all but the last dimension the same. Elements along the last dimension contain the unions.
Show Example
import tensorflow as tf
import collections # [[{1, 2}, {3}], [{4}, {5, 6}]]
a = collections.OrderedDict([
((0, 0, 0), 1),
((0, 0, 1), 2),
((0, 1, 0), 3),
((1, 0, 0), 4),
((1, 1, 0), 5),
((1, 1, 1), 6),
])
a = tf.SparseTensor(list(a.keys()), list(a.values()), dense_shape=[2, 2, 2]) # [[{1, 3}, {2}], [{4, 5}, {5, 6, 7, 8}]]
b = collections.OrderedDict([
((0, 0, 0), 1),
((0, 0, 1), 3),
((0, 1, 0), 2),
((1, 0, 0), 4),
((1, 0, 1), 5),
((1, 1, 0), 5),
((1, 1, 1), 6),
((1, 1, 2), 7),
((1, 1, 3), 8),
])
b = tf.SparseTensor(list(b.keys()), list(b.values()), dense_shape=[2, 2, 4]) # `set_union` is applied to each aligned pair of sets.
tf.sets.union(a, b) # The result will be a equivalent to either of:
#
# np.array([[{1, 2, 3}, {2, 3}], [{4, 5}, {5, 6, 7, 8}]])
#
# collections.OrderedDict([
# ((0, 0, 0), 1),
# ((0, 0, 1), 2),
# ((0, 0, 2), 3),
# ((0, 1, 0), 2),
# ((0, 1, 1), 3),
# ((1, 0, 0), 4),
# ((1, 0, 1), 5),
# ((1, 1, 0), 5),
# ((1, 1, 1), 6),
# ((1, 1, 2), 7),
# ((1, 1, 3), 8),
# ])
object union_dyn(object a, object b, ImplicitContainer<T> validate_indices)
Compute set union of elements in last dimension of `a` and `b`. All but the last dimension of `a` and `b` must match. Example:
Parameters
-
objecta - `Tensor` or `SparseTensor` of the same type as `b`. If sparse, indices must be sorted in row-major order.
-
objectb - `Tensor` or `SparseTensor` of the same type as `a`. If sparse, indices must be sorted in row-major order.
-
ImplicitContainer<T>validate_indices - Whether to validate the order and range of sparse indices in `a` and `b`.
Returns
-
object - A `SparseTensor` whose shape is the same rank as `a` and `b`, and all but the last dimension the same. Elements along the last dimension contain the unions.
Show Example
import tensorflow as tf
import collections # [[{1, 2}, {3}], [{4}, {5, 6}]]
a = collections.OrderedDict([
((0, 0, 0), 1),
((0, 0, 1), 2),
((0, 1, 0), 3),
((1, 0, 0), 4),
((1, 1, 0), 5),
((1, 1, 1), 6),
])
a = tf.SparseTensor(list(a.keys()), list(a.values()), dense_shape=[2, 2, 2]) # [[{1, 3}, {2}], [{4, 5}, {5, 6, 7, 8}]]
b = collections.OrderedDict([
((0, 0, 0), 1),
((0, 0, 1), 3),
((0, 1, 0), 2),
((1, 0, 0), 4),
((1, 0, 1), 5),
((1, 1, 0), 5),
((1, 1, 1), 6),
((1, 1, 2), 7),
((1, 1, 3), 8),
])
b = tf.SparseTensor(list(b.keys()), list(b.values()), dense_shape=[2, 2, 4]) # `set_union` is applied to each aligned pair of sets.
tf.sets.union(a, b) # The result will be a equivalent to either of:
#
# np.array([[{1, 2, 3}, {2, 3}], [{4, 5}, {5, 6, 7, 8}]])
#
# collections.OrderedDict([
# ((0, 0, 0), 1),
# ((0, 0, 1), 2),
# ((0, 0, 2), 3),
# ((0, 1, 0), 2),
# ((0, 1, 1), 3),
# ((1, 0, 0), 4),
# ((1, 0, 1), 5),
# ((1, 1, 0), 5),
# ((1, 1, 1), 6),
# ((1, 1, 2), 7),
# ((1, 1, 3), 8),
# ])