Link Search Menu Expand Document

InTopK


tensorflow C++ API

tensorflow::ops::InTopK

Says whether the targets are in the top Kpredictions.


Summary

This outputs abatch_sizebool array, an entryout[i]istrueif the prediction for the target class is among the topkpredictions among all predictions for examplei. Note that the behavior ofInTopKdiffers from theTopKop in its handling of ties; if multiple classes have the same prediction value and straddle the top-kboundary, all of those classes are considered to be in the topk.

More formally, let

\(predictions_i\) be the predictions for all classes for examplei, \(targets_i\) be the target class for examplei, \(out_i\) be the output for examplei,

\[out\_i = predictions\_{i, targets\_i} TopKIncludingTies\(predictions\_i\)\]

Arguments:

  • scope: A Scope object
  • predictions: A batch_sizex classestensor.
  • targets: A batch_sizevector of class ids.
  • k: Number of top elements to look at for computing precision.

Returns:


InTopK block

Source link : https://github.com/EXPNUNI/enuSpaceTensorflow/blob/master/enuSpaceTensorflow/tf_nn.cpp

Argument:

  • Scope scope : A Scope object (A scope is generated automatically each page. A scope is not connected.)
  • Input predictions: connect Input node.
  • Input targets: connect Input node.
  • int64 k: Input k in value ex)1

Return:

  • Output output: Output object of InTopK class object.

Result:

  • std::vector(Tensor) result_precision : Returned object of executed result by calling session.

Using Method