# tensorflow::ops::InTopKV2 Class Reference

# tensorflow::ops::InTopKV2

`#include <nn_ops.h>`

Says whether the targets are in the top `K` predictions.

## Summary

This outputs a `batch_size` bool array, an entry `out[i]` is `true` if the prediction for the target class is among the top `k` predictions among all predictions for example `i`. Note that the behavior of `https://www.tensorflow.org/versions/r2.8/api_docs/cc/class/tensorflow/ops/in-top-k#classtensorflow_1_1ops_1_1_in_top_k` differs from the `https://www.tensorflow.org/versions/r2.8/api_docs/cc/class/tensorflow/ops/top-k#classtensorflow_1_1ops_1_1_top_k` op in its handling of ties; if multiple classes have the same prediction value and straddle the top-`k` boundary, all of those classes are considered to be in the top `k`.

More formally, let

\\(predictions_i\\) be the predictions for all classes for example `i`, \\(targets_i\\) be the target class for example `i`, \\(out_i\\) be the output for example `i`,

$$out_i = predictions_{i, targets_i} \\in TopKIncludingTies(predictions_i)$$

Args:

- scope: A [Scope](https://www.tensorflow.org/versions/r2.8/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_scope) object
- predictions: A `batch_size` x `classes` tensor.
- targets: A `batch_size` vector of class ids.
- k: Number of top elements to look at for computing precision.

<br />

Returns:

- `https://www.tensorflow.org/versions/r2.8/api_docs/cc/class/tensorflow/output#classtensorflow_1_1_output`: Computed precision at `k` as a `bool https://www.tensorflow.org/versions/r2.8/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor`.

<br />

| ### Constructors and Destructors ||
|---|---|
| `https://www.tensorflow.org/versions/r2.8/api_docs/cc/class/tensorflow/ops/in-top-k-v2#classtensorflow_1_1ops_1_1_in_top_k_v2_1a7c731af26675d2a0a5e65d4bf0501a07(const ::https://www.tensorflow.org/versions/r2.8/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_scope & scope, ::https://www.tensorflow.org/versions/r2.8/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input predictions, ::https://www.tensorflow.org/versions/r2.8/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input targets, ::https://www.tensorflow.org/versions/r2.8/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input k)` ||

| ### Public attributes ||
|---|---|
| `https://www.tensorflow.org/versions/r2.8/api_docs/cc/class/tensorflow/ops/in-top-k-v2#classtensorflow_1_1ops_1_1_in_top_k_v2_1ad9127d0ee0e56405da77c8f8f0b0ad34` | `https://www.tensorflow.org/versions/r2.8/api_docs/cc/class/tensorflow/operation#classtensorflow_1_1_operation` |
| `https://www.tensorflow.org/versions/r2.8/api_docs/cc/class/tensorflow/ops/in-top-k-v2#classtensorflow_1_1ops_1_1_in_top_k_v2_1a66a3668a94dcfe6ed4412c6d48fac92b` | `::https://www.tensorflow.org/versions/r2.8/api_docs/cc/class/tensorflow/output#classtensorflow_1_1_output` |

| ### Public functions ||
|---|---|
| `https://www.tensorflow.org/versions/r2.8/api_docs/cc/class/tensorflow/ops/in-top-k-v2#classtensorflow_1_1ops_1_1_in_top_k_v2_1aca4c7a082803ec5e95dfcafac0999657() const ` | `::tensorflow::Node *` |
| `https://www.tensorflow.org/versions/r2.8/api_docs/cc/class/tensorflow/ops/in-top-k-v2#classtensorflow_1_1ops_1_1_in_top_k_v2_1a7197986e89c2315b1a6458dcffdfd0d5() const ` |   |
| `https://www.tensorflow.org/versions/r2.8/api_docs/cc/class/tensorflow/ops/in-top-k-v2#classtensorflow_1_1ops_1_1_in_top_k_v2_1aa8a166a0b803daf34df7fd9ef3c91d40() const ` |   |

## Public attributes

### operation

```
Operation operation
```

### precision

```
::tensorflow::Output precision
```

## Public functions

### InTopKV2

```
 InTopKV2(
  const ::tensorflow::Scope & scope,
  ::tensorflow::Input predictions,
  ::tensorflow::Input targets,
  ::tensorflow::Input k
)
```

### node

```
::tensorflow::Node * node() const 
```

### operator::tensorflow::Input

```
 operator::tensorflow::Input() const 
```

### operator::tensorflow::Output

```
 operator::tensorflow::Output() const 
```