UNPKG

2.74 kBTypeScriptView Raw
1/**
2 * @license
3 * Copyright 2018 Google LLC
4 *
5 * Use of this source code is governed by an MIT-style
6 * license that can be found in the LICENSE file or at
7 * https://opensource.org/licenses/MIT.
8 * =============================================================================
9 */
10/// <amd-module name="@tensorflow/tfjs-layers/dist/metrics" />
11import { Tensor } from '@tensorflow/tfjs-core';
12import { categoricalCrossentropy as categoricalCrossentropyLoss, cosineProximity, meanAbsoluteError, meanAbsolutePercentageError, meanSquaredError, sparseCategoricalCrossentropy as sparseCategoricalCrossentropyLoss } from './losses';
13import { LossOrMetricFn } from './types';
14export declare function binaryAccuracy(yTrue: Tensor, yPred: Tensor): Tensor;
15export declare function categoricalAccuracy(yTrue: Tensor, yPred: Tensor): Tensor;
16export declare function precision(yTrue: Tensor, yPred: Tensor): Tensor;
17export declare function recall(yTrue: Tensor, yPred: Tensor): Tensor;
18export declare function binaryCrossentropy(yTrue: Tensor, yPred: Tensor): Tensor;
19export declare function sparseCategoricalAccuracy(yTrue: Tensor, yPred: Tensor): Tensor;
20export declare function topKCategoricalAccuracy(yTrue: Tensor, yPred: Tensor): Tensor;
21export declare function sparseTopKCategoricalAccuracy(yTrue: Tensor, yPred: Tensor): Tensor;
22export declare const mse: typeof meanSquaredError;
23export declare const MSE: typeof meanSquaredError;
24export declare const mae: typeof meanAbsoluteError;
25export declare const MAE: typeof meanAbsoluteError;
26export declare const mape: typeof meanAbsolutePercentageError;
27export declare const MAPE: typeof meanAbsolutePercentageError;
28export declare const categoricalCrossentropy: typeof categoricalCrossentropyLoss;
29export declare const cosine: typeof cosineProximity;
30export declare const sparseCategoricalCrossentropy: typeof sparseCategoricalCrossentropyLoss;
31export declare const metricsMap: {
32 [functionName: string]: LossOrMetricFn;
33};
34export declare function get(identifier: string | LossOrMetricFn): LossOrMetricFn;
35/**
36 * Get the shortcut function name.
37 *
38 * If the fn name is a string,
39 * directly return the string name.
40 * If the function is included in metricsMap or lossesMap,
41 * return key of the map.
42 * - If the function relative to multiple keys,
43 * return the first found key as the function name.
44 * - If the function exists in both lossesMap and metricsMap,
45 * search lossesMap first.
46 * If the function is not included in metricsMap or lossesMap,
47 * return the function name.
48 *
49 * @param fn loss function, metric function, or short cut name.
50 * @returns Loss or Metric name in string.
51 */
52export declare function getLossOrMetricName(fn: string | LossOrMetricFn): string;