mindspore.ops.InTopK

class mindspore.ops.InTopK(k)[source]

Determines whether the targets are in the top k predictions.

Refer to mindspore.ops.intopk() for more details.

Supported Platforms:

Ascend GPU CPU

Examples

>>> x1 = Tensor(np.array([[1, 8, 5, 2, 7], [4, 9, 1, 3, 5]]), mindspore.float32)
>>> x2 = Tensor(np.array([1, 3]), mindspore.int32)
>>> in_top_k = ops.InTopK(3)
>>> output = in_top_k(x1, x2)
>>> print(output)
[ True  False]