Stay organized with collections
Save and categorize content based on your preferences.
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
InTopK
differs from the
TopK
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} TopKIncludingTies(predictions_i)$$
Args:
-
scope: A
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.
Returns:
Public attributes
Public functions
node
::tensorflow::Node * node() const
operator::tensorflow::Input() const
operator::tensorflow::Output
operator::tensorflow::Output() const
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates. Some content is licensed under the numpy license.
Last updated 2021-05-14 UTC.
[null,null,["Last updated 2021-05-14 UTC."],[],[],null,["# tensorflow::ops::InTopKV2 Class Reference\n\ntensorflow::\nops::\nInTopKV2\n===========================\n\n`\n#include \u003cnn_ops.h\u003e\n`\n\n\nSays whether the targets are in the top\n`\nK\n`\npredictions.\n\nSummary\n-------\n\n\nThis outputs a\n`\nbatch_size\n`\nbool array, an entry\n`\nout[i]\n`\nis\n`\ntrue\n`\nif the prediction for the target class is among the top\n`\nk\n`\npredictions among all predictions for example\n`\ni\n`\n. Note that the behavior of\n`\n`[InTopK](/versions/r2.5/api_docs/cc/class/tensorflow/ops/in-top-k#classtensorflow_1_1ops_1_1_in_top_k)`\n`\ndiffers from the\n`\n`[TopK](/versions/r2.5/api_docs/cc/class/tensorflow/ops/top-k#classtensorflow_1_1ops_1_1_top_k)`\n`\nop in its handling of ties; if multiple classes have the same prediction value and straddle the top-\n`\nk\n`\nboundary, all of those classes are considered to be in the top\n`\nk\n`\n.\n\n\nMore formally, let\n\n\n\\\\(predictions_i\\\\) be the predictions for all classes for example\n`\ni\n`\n, \\\\(targets_i\\\\) be the target class for example\n`\ni\n`\n, \\\\(out_i\\\\) be the output for example\n`\ni\n`\n,\n\n\n$$out_i = predictions_{i, targets_i} TopKIncludingTies(predictions_i)$$\n\n\u003cbr /\u003e\n\n\nArgs:\n\n- scope: A [Scope](/versions/r2.5/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_scope) object\n- predictions: A `\n batch_size\n ` x `\n classes\n ` tensor.\n- targets: A `\n batch_size\n ` vector of class ids.\n- k: Number of top elements to look at for computing precision.\n\n\u003cbr /\u003e\n\n\nReturns:\n\n- `\n `[Output](/versions/r2.5/api_docs/cc/class/tensorflow/output#classtensorflow_1_1_output)`\n ` : Computed precision at `\n k\n ` as a `\n bool\n `[Tensor](/versions/r2.5/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor)`\n ` .\n\n\u003cbr /\u003e\n\n| ### Constructors and Destructors ||\n|---|---|\n| ` `[InTopKV2](#classtensorflow_1_1ops_1_1_in_top_k_v2_1a7c731af26675d2a0a5e65d4bf0501a07)` (const :: `[tensorflow::Scope](/versions/r2.5/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_scope)` & scope, :: `[tensorflow::Input](/versions/r2.5/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` predictions, :: `[tensorflow::Input](/versions/r2.5/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` targets, :: `[tensorflow::Input](/versions/r2.5/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` k) ` ||\n\n| ### Public attributes ||\n|-----------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------|\n| ` `[operation](#classtensorflow_1_1ops_1_1_in_top_k_v2_1ad9127d0ee0e56405da77c8f8f0b0ad34)` ` | ` `[Operation](/versions/r2.5/api_docs/cc/class/tensorflow/operation#classtensorflow_1_1_operation)` ` |\n| ` `[precision](#classtensorflow_1_1ops_1_1_in_top_k_v2_1a66a3668a94dcfe6ed4412c6d48fac92b)` ` | ` :: `[tensorflow::Output](/versions/r2.5/api_docs/cc/class/tensorflow/output#classtensorflow_1_1_output)` ` |\n\n| ### Public functions ||\n|---------------------------------------------------------------------------------------------------------------------------|--------------------------|\n| ` `[node](#classtensorflow_1_1ops_1_1_in_top_k_v2_1aca4c7a082803ec5e95dfcafac0999657)` () const ` | ` ::tensorflow::Node * ` |\n| ` `[operator::tensorflow::Input](#classtensorflow_1_1ops_1_1_in_top_k_v2_1a7197986e89c2315b1a6458dcffdfd0d5)` () const ` | ` ` |\n| ` `[operator::tensorflow::Output](#classtensorflow_1_1ops_1_1_in_top_k_v2_1aa8a166a0b803daf34df7fd9ef3c91d40)` () const ` | ` ` |\n\nPublic attributes\n-----------------\n\n### operation\n\n```text\nOperation operation\n``` \n\n### precision\n\n```text\n::tensorflow::Output precision\n``` \n\nPublic functions\n----------------\n\n### InTopKV2\n\n```gdscript\n InTopKV2(\n const ::tensorflow::Scope & scope,\n ::tensorflow::Input predictions,\n ::tensorflow::Input targets,\n ::tensorflow::Input k\n)\n``` \n\n### node\n\n```gdscript\n::tensorflow::Node * node() const \n``` \n\n### operator::tensorflow::Input\n\n```gdscript\n operator::tensorflow::Input() const \n``` \n\n### operator::tensorflow::Output\n\n```gdscript\n operator::tensorflow::Output() const \n```"]]