UNPKG

1.58 kBTypeScriptView Raw
1/**
2 * @license
3 * Copyright 2019 Google LLC. All Rights Reserved.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 * =============================================================================
16 */
17import { Tensor } from '../tensor';
18import { TensorLike } from '../types';
19/**
20 * Returns whether the targets are in the top K predictions.
21 *
22 * ```js
23 * const predictions = tf.tensor2d([[20, 10, 40, 30], [30, 50, -20, 10]]);
24 * const targets = tf.tensor1d([2, 0]);
25 * const precision = await tf.inTopKAsync(predictions, targets);
26 * precision.print();
27 * ```
28 * @param predictions 2-D or higher `tf.Tensor` with last dimension being
29 * at least `k`.
30 * @param targets 1-D or higher `tf.Tensor`.
31 * @param k Optional Number of top elements to look at for computing precision,
32 * default to 1.
33 *
34 * @doc {heading: 'Operations', subheading: 'Evaluation'}
35 */
36declare function inTopKAsync_<T extends Tensor, U extends Tensor>(predictions: T | TensorLike, targets: U | TensorLike, k?: number): Promise<U>;
37export declare const inTopKAsync: typeof inTopKAsync_;
38export {};