# ApproxTopK

public final class **ApproxTopK** Returns min/max k values and their indices of the input operand in an approximate manner.


See https://arxiv.org/abs/2206.14286 for the algorithm details.
This op is only optimized on TPU currently.

<br />

### Nested Classes

|---|---|---|---|
| class | [ApproxTopK.Options](https://www.tensorflow.org/api_docs/java/org/tensorflow/op/core/ApproxTopK.Options) || Optional attributes for `https://www.tensorflow.org/api_docs/java/org/tensorflow/op/core/ApproxTopK` |

### Public Methods

|---|---|
| static [ApproxTopK.Options](https://www.tensorflow.org/api_docs/java/org/tensorflow/op/core/ApproxTopK.Options) | [aggregateToTopk](https://www.tensorflow.org/api_docs/java/org/tensorflow/op/core/ApproxTopK#aggregateToTopk(java.lang.Boolean))(Boolean aggregateToTopk) |
| static \<T extends Number\> [ApproxTopK](https://www.tensorflow.org/api_docs/java/org/tensorflow/op/core/ApproxTopK)\<T\> | [create](https://www.tensorflow.org/api_docs/java/org/tensorflow/op/core/ApproxTopK#create(org.tensorflow.op.Scope,%20org.tensorflow.Operand<T>,%20java.lang.Long,%20org.tensorflow.op.core.ApproxTopK.Options...))([Scope](https://www.tensorflow.org/api_docs/java/org/tensorflow/op/Scope) scope, [Operand](https://www.tensorflow.org/api_docs/java/org/tensorflow/Operand)\<T\> input, Long k, [Options...](https://www.tensorflow.org/api_docs/java/org/tensorflow/op/core/ApproxTopK.Options) options) Factory method to create a class wrapping a new ApproxTopK operation. |
| [Output](https://www.tensorflow.org/api_docs/java/org/tensorflow/Output)\<Integer\> | [indices](https://www.tensorflow.org/api_docs/java/org/tensorflow/op/core/ApproxTopK#indices())() The indices of \`values\` along the \`reduction_dimension\` of the \`input\` operand. |
| static [ApproxTopK.Options](https://www.tensorflow.org/api_docs/java/org/tensorflow/op/core/ApproxTopK.Options) | [isMaxK](https://www.tensorflow.org/api_docs/java/org/tensorflow/op/core/ApproxTopK#isMaxK(java.lang.Boolean))(Boolean isMaxK) |
| static [ApproxTopK.Options](https://www.tensorflow.org/api_docs/java/org/tensorflow/op/core/ApproxTopK.Options) | [recallTarget](https://www.tensorflow.org/api_docs/java/org/tensorflow/op/core/ApproxTopK#recallTarget(java.lang.Float))(Float recallTarget) |
| static [ApproxTopK.Options](https://www.tensorflow.org/api_docs/java/org/tensorflow/op/core/ApproxTopK.Options) | [reductionDimension](https://www.tensorflow.org/api_docs/java/org/tensorflow/op/core/ApproxTopK#reductionDimension(java.lang.Long))(Long reductionDimension) |
| static [ApproxTopK.Options](https://www.tensorflow.org/api_docs/java/org/tensorflow/op/core/ApproxTopK.Options) | [reductionInputSizeOverride](https://www.tensorflow.org/api_docs/java/org/tensorflow/op/core/ApproxTopK#reductionInputSizeOverride(java.lang.Long))(Long reductionInputSizeOverride) |
| [Output](https://www.tensorflow.org/api_docs/java/org/tensorflow/Output)\<T\> | [values](https://www.tensorflow.org/api_docs/java/org/tensorflow/op/core/ApproxTopK#values())() The min/max k values along the \`reduction_dimension\` of the \`input\` operand. |

### Inherited Methods

From class [org.tensorflow.op.PrimitiveOp](https://www.tensorflow.org/api_docs/java/org/tensorflow/op/PrimitiveOp)

|---|---|
| final boolean | [equals](https://www.tensorflow.org/api_docs/java/org/tensorflow/op/PrimitiveOp#equals(java.lang.Object))(Object obj) |
| final int | [hashCode](https://www.tensorflow.org/api_docs/java/org/tensorflow/op/PrimitiveOp#hashCode())() |
| [Operation](https://www.tensorflow.org/api_docs/java/org/tensorflow/Operation) | [op](https://www.tensorflow.org/api_docs/java/org/tensorflow/op/PrimitiveOp#op())() Returns the underlying `https://www.tensorflow.org/api_docs/java/org/tensorflow/Operation` |
| final String | [toString](https://www.tensorflow.org/api_docs/java/org/tensorflow/op/PrimitiveOp#toString())() |

From class java.lang.Object

|---|---|
| boolean | equals(Object arg0) |
| final Class\<?\> | getClass() |
| int | hashCode() |
| final void | notify() |
| final void | notifyAll() |
| String | toString() |
| final void | wait(long arg0, int arg1) |
| final void | wait(long arg0) |
| final void | wait() |

## Public Methods

#### public static [ApproxTopK.Options](https://www.tensorflow.org/api_docs/java/org/tensorflow/op/core/ApproxTopK.Options)
**aggregateToTopk**
(Boolean aggregateToTopk)

<br />

##### Parameters

| aggregateToTopk | 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\`. |
|---|---|

#### public static [ApproxTopK](https://www.tensorflow.org/api_docs/java/org/tensorflow/op/core/ApproxTopK)\<T\>
**create**
([Scope](https://www.tensorflow.org/api_docs/java/org/tensorflow/op/Scope) scope, [Operand](https://www.tensorflow.org/api_docs/java/org/tensorflow/Operand)\<T\> input, Long k, [Options...](https://www.tensorflow.org/api_docs/java/org/tensorflow/op/core/ApproxTopK.Options) options)

Factory method to create a class wrapping a new ApproxTopK operation.

##### Parameters

| scope | current scope |
| input | Array to search. Must be at least 1-D of the floating type |
| k | Specifies the number of min/max-k. |
| options | carries optional attributes values |
|---|---|

##### Returns

- a new instance of ApproxTopK

#### public [Output](https://www.tensorflow.org/api_docs/java/org/tensorflow/Output)\<Integer\>
**indices**
()

The indices of \`values\` along the \`reduction_dimension\` of the \`input\` operand.

#### public static [ApproxTopK.Options](https://www.tensorflow.org/api_docs/java/org/tensorflow/op/core/ApproxTopK.Options)
**isMaxK**
(Boolean isMaxK)

<br />

##### Parameters

| isMaxK | When true, computes max-k; otherwise computes min-k. |
|---|---|

#### public static [ApproxTopK.Options](https://www.tensorflow.org/api_docs/java/org/tensorflow/op/core/ApproxTopK.Options)
**recallTarget**
(Float recallTarget)

<br />

##### Parameters

| recallTarget | Recall target for the approximation. Range in (0,1\] |
|---|---|

#### public static [ApproxTopK.Options](https://www.tensorflow.org/api_docs/java/org/tensorflow/op/core/ApproxTopK.Options)
**reductionDimension**
(Long reductionDimension)

<br />

##### Parameters

| reductionDimension | Integer dimension along which to search. Default: -1. |
|---|---|

#### public static [ApproxTopK.Options](https://www.tensorflow.org/api_docs/java/org/tensorflow/op/core/ApproxTopK.Options)
**reductionInputSizeOverride**
(Long reductionInputSizeOverride)

<br />

##### Parameters

| reductionInputSizeOverride | 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. |
|---|---|

#### public [Output](https://www.tensorflow.org/api_docs/java/org/tensorflow/Output)\<T\>
**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.