Stay organized with collections
Save and categorize content based on your preferences.
tensorflow::ops::InTopK
#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)$$
Arguments:
- 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.
Last updated 2020-04-20 UTC.
[null,null,["Last updated 2020-04-20 UTC."],[],[],null,["# tensorflow::ops::InTopK Class Reference\n\ntensorflow::ops::InTopK\n=======================\n\n`#include \u003cnn_ops.h\u003e`\n\nSays whether the targets are in the top `K` predictions.\n\nSummary\n-------\n\nThis 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](/versions/r1.15/api_docs/cc/class/tensorflow/ops/in-top-k#classtensorflow_1_1ops_1_1_in_top_k) differs from the [TopK](/versions/r1.15/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`.\n\nMore formally, let\n\n\\\\(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`,\n\n$$out_i = predictions_{i, targets_i} TopKIncludingTies(predictions_i)$$\n\nArguments:\n\n- scope: A [Scope](/versions/r1.15/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_scope) object\n- predictions: A `batch_size` x `classes` tensor.\n- targets: A `batch_size` vector of class ids.\n- k: Number of top elements to look at for computing precision.\n\n\u003cbr /\u003e\n\nReturns:\n\n- [Output](/versions/r1.15/api_docs/cc/class/tensorflow/output#classtensorflow_1_1_output): Computed Precision at `k` as a `bool `[Tensor](/versions/r1.15/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor).\n\n\u003cbr /\u003e\n\n| ### Constructors and Destructors ||\n|---|---|\n| [InTopK](#classtensorflow_1_1ops_1_1_in_top_k_1a377574cc533f3b91fea7345442e1998f)`(const ::`[tensorflow::Scope](/versions/r1.15/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_scope)` & scope, ::`[tensorflow::Input](/versions/r1.15/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` predictions, ::`[tensorflow::Input](/versions/r1.15/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` targets, int64 k)` ||\n\n| ### Public attributes ||\n|--------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------|\n| [operation](#classtensorflow_1_1ops_1_1_in_top_k_1afe7a77dd6f17c474fce97861cab29527) | [Operation](/versions/r1.15/api_docs/cc/class/tensorflow/operation#classtensorflow_1_1_operation) |\n| [precision](#classtensorflow_1_1ops_1_1_in_top_k_1a43116d147476cd8f69ce01d5c3c9f915) | `::`[tensorflow::Output](/versions/r1.15/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_1a135e20737a15b73e8336cea65b60ad87)`() const ` | `::tensorflow::Node *` |\n| [operator::tensorflow::Input](#classtensorflow_1_1ops_1_1_in_top_k_1a0b88d86f83d7e064c8c3189793a3400b)`() const ` | ` ` ` ` |\n| [operator::tensorflow::Output](#classtensorflow_1_1ops_1_1_in_top_k_1a63713331ec8812a5470f740a7fd9f5df)`() 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### InTopK\n\n```gdscript\n InTopK(\n const ::tensorflow::Scope & scope,\n ::tensorflow::Input predictions,\n ::tensorflow::Input targets,\n int64 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```"]]