W3cubDocs

/TensorFlow Python

tf.sets.set_intersection(a, b, validate_indices=True)

tf.contrib.metrics.set_intersection(a, b, validate_indices=True)

tf.sets.set_intersection(a, b, validate_indices=True)

See the guide: Metrics (contrib) > Set Ops

Compute set intersection of elements in last dimension of a and b.

All but the last dimension of a and b must match.

Example:

a = [
  [
    [
      [1, 2],
      [3],
    ],
    [
      [4],
      [5, 6],
    ],
  ],
]
b = [
  [
    [
      [1, 3],
      [2],
    ],
    [
      [4, 5],
      [5, 6, 7, 8],
    ],
  ],
]
set_intersection(a, b) = [
  [
    [
      [1],
      [],
    ],
    [
      [4],
      [5, 6],
    ],
  ],
]

Args:

  • a: Tensor or SparseTensor of the same type as b. If sparse, indices must be sorted in row-major order.
  • b: Tensor or SparseTensor of the same type as a. If sparse, indices must be sorted in row-major order.
  • validate_indices: Whether to validate the order and range of sparse indices in a and b.

Returns:

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.

Defined in tensorflow/python/ops/sets_impl.py.

© 2017 The TensorFlow Authors. All rights reserved.
Licensed under the Creative Commons Attribution License 3.0.
Code samples licensed under the Apache 2.0 License.
https://www.tensorflow.org/api_docs/python/tf/sets/set_intersection