# Set Ops

### tf.contrib.metrics.set_difference(a, b, aminusb=True, validate_indices=True)

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

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

##### 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. Must be SparseTensor if a is SparseTensor. If sparse, indices must be sorted in row-major order.
• aminusb: Whether to subtract b from a, vs vice versa.
• validate_indices: Whether to validate the order and range of sparse indices in a and b.
##### Returns:

A SparseTensor with the same rank as a and b, and all but the last dimension the same. Elements along the last dimension contain the differences.

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

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

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

##### 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. Must be SparseTensor if a is SparseTensor. 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 with the same rank as a and b, and all but the last dimension the same. Elements along the last dimension contain the intersections.

### tf.contrib.metrics.set_size(a, validate_indices=True)

Compute number of unique elements along last dimension of a.

##### Args:
• a: SparseTensor, with indices sorted in row-major order.
• validate_indices: Whether to validate the order and range of sparse indices in a.
##### Returns:

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.

##### Raises:
• TypeError: If a is an invalid types.

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

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

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

##### 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. Must be SparseTensor if a is SparseTensor. 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 with the same rank as a and b, and all but the last dimension the same. Elements along the last dimension contain the unions.