Returns whether the targets are in the top K predictions.
const predictions = tf.tensor2d([[20, 10, 40, 30], [30, 50, -20, 10]]);const targets = tf.tensor1d([2, 0]);const precision = await tf.inTopKAsync(predictions, targets);precision.print(); Copy
const predictions = tf.tensor2d([[20, 10, 40, 30], [30, 50, -20, 10]]);const targets = tf.tensor1d([2, 0]);const precision = await tf.inTopKAsync(predictions, targets);precision.print();
2-D or higher tf.Tensor with last dimension being at least k.
tf.Tensor
k
1-D or higher tf.Tensor.
Optional
Optional Number of top elements to look at for computing precision, default to 1.
Generated using TypeDoc
Returns whether the targets are in the top K predictions.