@Operator public final class InTopK extends PrimitiveOp implements Operand<Boolean>
This outputs a `batch_size` bool array, an entry `out[i]` is `true` if the prediction for the target class is among the top `k` predictions among all predictions for example `i`. Note that the behavior of `InTopK` differs from the `TopK` op in its handling of ties; if multiple classes have the same prediction value and straddle the top-`k` boundary, all of those classes are considered to be in the top `k`.
More formally, let
\\(predictions_i\\) be the predictions for all classes for example `i`, \\(targets_i\\) be the target class for example `i`, \\(out_i\\) be the output for example `i`,
$$out_i = predictions_{i, targets_i} \in TopKIncludingTies(predictions_i)$$
operation| Modifier and Type | Method and Description |
|---|---|
Output<Boolean> |
asOutput()
Returns the symbolic handle of a tensor.
|
static <T extends Number> |
create(Scope scope,
Operand<Float> predictions,
Operand<T> targets,
Long k)
Factory method to create a class to wrap a new InTopK operation to the graph.
|
Output<Boolean> |
precision()
Computed Precision at `k` as a `bool Tensor`.
|
equals, hashCode, toStringpublic static <T extends Number> InTopK create(Scope scope, Operand<Float> predictions, Operand<T> targets, Long k)
scope - current graph scopepredictions - A `batch_size` x `classes` tensor.targets - A `batch_size` vector of class ids.k - Number of top elements to look at for computing precision.public Output<Boolean> asOutput()
OperandInputs to TensorFlow operations are outputs of another TensorFlow operation. This method is used to obtain a symbolic handle that represents the computation of the input.
asOutput in interface Operand<Boolean>OperationBuilder.addInput(Output)Copyright © 2015–2019. All rights reserved.