File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed
python/paddle/v2/fluid/layers Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -485,6 +485,30 @@ def max_sequence_len(rank_table):
485485
486486
487487def topk (input , k ):
488+ """
489+ **topk**
490+
491+ This function performs the operation that selects the k entries in the input
492+ vector and outputs their values and indices as vectors. Thus topk_out[j] is
493+ the j-th largest entry in input, and its index is topk_indices[j]
494+
495+ Args:
496+ input (Variable|list): The input tensor that has all the data.
497+ k (int): The number of top elements that the function will pick.
498+
499+ Returns:
500+ Variable: The variable of type array that contains the k largest entries
501+ from input.
502+ Variable: The variable of type array that contains the indices of k
503+ largest entries from input.
504+
505+ Examples:
506+ .. code-block:: python
507+
508+ x = fluid.layers.data(name='x', shape=[10])
509+ k = 5
510+ array = fluid.layers.topk(x, k)
511+ """
488512 helper = LayerHelper ('topk' , ** locals ())
489513 topk_out = helper .create_tmp_variable (dtype = input .data_type )
490514 topk_indices = helper .create_tmp_variable (dtype = 'int64' )
You can’t perform that action at this time.
0 commit comments