Stay organized with collections
Save and categorize content based on your preferences.
tensorflow::ops::ApproxTopK
#include <nn_ops.h>
Returns min/max k values and their indices of the input operand in an approximate manner.
Summary
See https://arxiv.org/abs/2206.14286 for the algorithm details. This op is only optimized on TPU currently.
Args:
- scope: A Scope object
- input: Array to search. Must be at least 1-D of the floating type
- k: Specifies the number of min/max-k.
Optional attributes (see Attrs
):
- reduction_dimension: Integer dimension along which to search. Default: -1.
- recall_target: Recall target for the approximation. Range in (0,1]
- is_max_k: When true, computes max-k; otherwise computes min-k.
- reduction_input_size_override: When set to a positive value, it overrides the size determined by
input[reduction_dim]
for evaluating the recall. This option is useful when the given input
is only a subset of the overall computation in SPMD or distributed pipelines, where the true input size cannot be deferred by the input
shape.
- aggregate_to_topk: When true, aggregates approximate results to top-k. When false, returns the approximate results. The number of the approximate results is implementation defined and is greater equals to the specified
k
.
Returns:
Output
values: The min/max k values along the reduction_dimension
of the input
operand. The dimension are the same as the input
operand except for the reduction_dimension
: when aggregate_to_topk
is true, the reduction dimension is k
; otherwise, it is greater equals to k
where the size is implementation-defined.
Output
indices: The indices of values
along the reduction_dimension
of the input
operand.
Public attributes
Public functions
Public static functions
AggregateToTopk
Attrs AggregateToTopk(
bool x
)
IsMaxK
Attrs IsMaxK(
bool x
)
RecallTarget
Attrs RecallTarget(
float x
)
ReductionDimension
Attrs ReductionDimension(
int64 x
)
Attrs ReductionInputSizeOverride(
int64 x
)
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 2023-10-06 UTC.
[null,null,["Last updated 2023-10-06 UTC."],[],[],null,["# tensorflow::ops::ApproxTopK Class Reference\n\ntensorflow::ops::ApproxTopK\n===========================\n\n`#include \u003cnn_ops.h\u003e`\n\nReturns min/max k values and their indices of the input operand in an approximate manner.\n\nSummary\n-------\n\nSee \u003chttps://arxiv.org/abs/2206.14286\u003e for the algorithm details. This op is only optimized on TPU currently.\n\nArgs:\n\n- scope: A [Scope](/versions/r2.14/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_scope) object\n- input: Array to search. Must be at least 1-D of the floating type\n- k: Specifies the number of min/max-k.\n\n\u003cbr /\u003e\n\nOptional attributes (see [Attrs](/versions/r2.14/api_docs/cc/struct/tensorflow/ops/approx-top-k/attrs#structtensorflow_1_1ops_1_1_approx_top_k_1_1_attrs)):\n\n- reduction_dimension: Integer dimension along which to search. Default: -1.\n- recall_target: Recall target for the approximation. [Range](/versions/r2.14/api_docs/cc/class/tensorflow/ops/range#classtensorflow_1_1ops_1_1_range) in (0,1\\]\n- is_max_k: When true, computes max-k; otherwise computes min-k.\n- reduction_input_size_override: When set to a positive value, it overrides the size determined by `input[reduction_dim]` for evaluating the recall. This option is useful when the given `input` is only a subset of the overall computation in SPMD or distributed pipelines, where the true input size cannot be deferred by the `input` shape.\n- aggregate_to_topk: When true, aggregates approximate results to top-k. When false, returns the approximate results. The number of the approximate results is implementation defined and is greater equals to the specified `k`.\n\n\u003cbr /\u003e\n\nReturns:\n\n- [Output](/versions/r2.14/api_docs/cc/class/tensorflow/output#classtensorflow_1_1_output) values: The min/max k values along the `reduction_dimension` of the `input` operand. The dimension are the same as the `input` operand except for the `reduction_dimension`: when `aggregate_to_topk` is true, the reduction dimension is `k`; otherwise, it is greater equals to `k` where the size is implementation-defined.\n- [Output](/versions/r2.14/api_docs/cc/class/tensorflow/output#classtensorflow_1_1_output) indices: The indices of `values` along the `reduction_dimension` of the `input` operand.\n\n\u003cbr /\u003e\n\n| ### Constructors and Destructors ||\n|---|---|\n| [ApproxTopK](#classtensorflow_1_1ops_1_1_approx_top_k_1ad907e075d285236d3a304c74656f3fce)`(const ::`[tensorflow::Scope](/versions/r2.14/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_scope)` & scope, ::`[tensorflow::Input](/versions/r2.14/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` input, int64 k)` ||\n| [ApproxTopK](#classtensorflow_1_1ops_1_1_approx_top_k_1ad1fbdbeaf88943d4459ab5473a6d083b)`(const ::`[tensorflow::Scope](/versions/r2.14/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_scope)` & scope, ::`[tensorflow::Input](/versions/r2.14/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` input, int64 k, const `[ApproxTopK::Attrs](/versions/r2.14/api_docs/cc/struct/tensorflow/ops/approx-top-k/attrs#structtensorflow_1_1ops_1_1_approx_top_k_1_1_attrs)` & attrs)` ||\n\n| ### Public attributes ||\n|------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------|\n| [indices](#classtensorflow_1_1ops_1_1_approx_top_k_1a2b62da2738c0559689c4d9fd8ada1247) | `::`[tensorflow::Output](/versions/r2.14/api_docs/cc/class/tensorflow/output#classtensorflow_1_1_output) |\n| [operation](#classtensorflow_1_1ops_1_1_approx_top_k_1af62886f2c295b35d192005c4ccb87e0b) | [Operation](/versions/r2.14/api_docs/cc/class/tensorflow/operation#classtensorflow_1_1_operation) |\n| [values](#classtensorflow_1_1ops_1_1_approx_top_k_1a499ea415612ccef8b57503158853a0f6) | `::`[tensorflow::Output](/versions/r2.14/api_docs/cc/class/tensorflow/output#classtensorflow_1_1_output) |\n\n| ### Public static functions ||\n|----------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------|\n| [AggregateToTopk](#classtensorflow_1_1ops_1_1_approx_top_k_1a1474aabf2f67851f27f4ec47c14c75e3)`(bool x)` | [Attrs](/versions/r2.14/api_docs/cc/struct/tensorflow/ops/approx-top-k/attrs#structtensorflow_1_1ops_1_1_approx_top_k_1_1_attrs) |\n| [IsMaxK](#classtensorflow_1_1ops_1_1_approx_top_k_1a19ea77e75970e6077b85e94cecfb56ed)`(bool x)` | [Attrs](/versions/r2.14/api_docs/cc/struct/tensorflow/ops/approx-top-k/attrs#structtensorflow_1_1ops_1_1_approx_top_k_1_1_attrs) |\n| [RecallTarget](#classtensorflow_1_1ops_1_1_approx_top_k_1a0acab585fe4e60ee0fa83e5244b96e0d)`(float x)` | [Attrs](/versions/r2.14/api_docs/cc/struct/tensorflow/ops/approx-top-k/attrs#structtensorflow_1_1ops_1_1_approx_top_k_1_1_attrs) |\n| [ReductionDimension](#classtensorflow_1_1ops_1_1_approx_top_k_1a3c89b1c3608339b0b5fbb4c7e3f4d31b)`(int64 x)` | [Attrs](/versions/r2.14/api_docs/cc/struct/tensorflow/ops/approx-top-k/attrs#structtensorflow_1_1ops_1_1_approx_top_k_1_1_attrs) |\n| [ReductionInputSizeOverride](#classtensorflow_1_1ops_1_1_approx_top_k_1a28cae1ddf7876a401792dd5242202f82)`(int64 x)` | [Attrs](/versions/r2.14/api_docs/cc/struct/tensorflow/ops/approx-top-k/attrs#structtensorflow_1_1ops_1_1_approx_top_k_1_1_attrs) |\n\n| ### Structs ||\n|------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------|\n| [tensorflow::ops::ApproxTopK::Attrs](/versions/r2.14/api_docs/cc/struct/tensorflow/ops/approx-top-k/attrs) | Optional attribute setters for [ApproxTopK](/versions/r2.14/api_docs/cc/class/tensorflow/ops/approx-top-k#classtensorflow_1_1ops_1_1_approx_top_k). |\n\nPublic attributes\n-----------------\n\n### indices\n\n```text\n::tensorflow::Output indices\n``` \n\n### operation\n\n```text\nOperation operation\n``` \n\n### values\n\n```text\n::tensorflow::Output values\n``` \n\nPublic functions\n----------------\n\n### ApproxTopK\n\n```gdscript\n ApproxTopK(\n const ::tensorflow::Scope & scope,\n ::tensorflow::Input input,\n int64 k\n)\n``` \n\n### ApproxTopK\n\n```gdscript\n ApproxTopK(\n const ::tensorflow::Scope & scope,\n ::tensorflow::Input input,\n int64 k,\n const ApproxTopK::Attrs & attrs\n)\n``` \n\nPublic static functions\n-----------------------\n\n### AggregateToTopk\n\n```verilog\nAttrs AggregateToTopk(\n bool x\n)\n``` \n\n### IsMaxK\n\n```text\nAttrs IsMaxK(\n bool x\n)\n``` \n\n### RecallTarget\n\n```text\nAttrs RecallTarget(\n float x\n)\n``` \n\n### ReductionDimension\n\n```text\nAttrs ReductionDimension(\n int64 x\n)\n``` \n\n### ReductionInputSizeOverride\n\n```text\nAttrs ReductionInputSizeOverride(\n int64 x\n)\n```"]]