tf.approx_top_k
    
    
      
    
    
      
      Stay organized with collections
    
    
      
      Save and categorize content based on your preferences.
    
  
  
      
    
  
  
  
  
  
    
  
  
    
    
Returns min/max k values and their indices of the input operand in an approximate manner.
tf.approx_top_k(
    input: Annotated[Any, TV_ApproxTopK_T],
    k: int,
    reduction_dimension: int = -1,
    recall_target: float = 0.95,
    is_max_k: bool = True,
    reduction_input_size_override: int = -1,
    aggregate_to_topk: bool = True,
    name=None
)
See https://arxiv.org/abs/2206.14286 for the algorithm details.
This op is only optimized on TPU currently.
| Args | 
|---|
| input | A Tensor. Must be one of the following types:half,bfloat16,float32.
Array to search. Must be at least 1-D of the floating type | 
| k | An intthat is>= 0. Specifies the number of min/max-k. | 
| reduction_dimension | An optional int. Defaults to-1.
Integer dimension along which to search. Default: -1. | 
| recall_target | An optional float. Defaults to0.95.
Recall target for the approximation. Range in (0,1] | 
| is_max_k | An optional bool. Defaults toTrue.
When true, computes max-k; otherwise computes min-k. | 
| reduction_input_size_override | An optional int. Defaults to-1.
When set to a positive value, it overrides the size determined byinput[reduction_dim]for evaluating the recall. This option is useful when
the giveninputis only a subset of the overall computation in SPMD or
distributed pipelines, where the true input size cannot be deferred by theinputshape. | 
| aggregate_to_topk | An optional bool. Defaults toTrue.
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 specifiedk. | 
| name | A name for the operation (optional). | 
| Returns | 
|---|
| A tuple of Tensorobjects (values, indices). | 
| values | A Tensor. Has the same type asinput. | 
| indices | A Tensorof typeint32. | 
  
  
 
  
    
    
      
       
    
    
  
  
  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 2024-04-26 UTC.
  
  
  
    
      [null,null,["Last updated 2024-04-26 UTC."],[],[]]