• 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();

    Type Parameters

    Parameters

    • predictions: TensorLike | T

      2-D or higher tf.Tensor with last dimension being at least k.

    • targets: TensorLike | U

      1-D or higher tf.Tensor.

    • Optional k: number

      Optional Number of top elements to look at for computing precision, default to 1.

    Returns Promise<U>

    Doc

Generated using TypeDoc