1 | /**
|
2 | * @license
|
3 | * Copyright 2018 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 | */
|
17 | /// <amd-module name="@tensorflow/tfjs-core/dist/ops/norm" />
|
18 | import { Tensor } from '../tensor';
|
19 | import { TensorLike } from '../types';
|
20 | /**
|
21 | * Computes the norm of scalar, vectors, and matrices.
|
22 | * This function can compute several different vector norms (the 1-norm, the
|
23 | * Euclidean or 2-norm, the inf-norm, and in general the p-norm for p > 0)
|
24 | * and matrix norms (Frobenius, 1-norm, and inf-norm).
|
25 | *
|
26 | * ```js
|
27 | * const x = tf.tensor1d([1, 2, 3, 4]);
|
28 | *
|
29 | * x.norm().print(); // or tf.norm(x)
|
30 | * ```
|
31 | *
|
32 | * @param x The input array.
|
33 | * @param ord Optional. Order of the norm. Supported norm types are
|
34 | * following:
|
35 | *
|
36 | * | ord | norm for matrices | norm for vectors
|
37 | * |------------|---------------------------|---------------------
|
38 | * |'euclidean' |Frobenius norm |2-norm
|
39 | * |'fro' |Frobenius norm |
|
40 | * |Infinity |max(sum(abs(x), axis=1)) |max(abs(x))
|
41 | * |-Infinity |min(sum(abs(x), axis=1)) |min(abs(x))
|
42 | * |1 |max(sum(abs(x), axis=0)) |sum(abs(x))
|
43 | * |2 | |sum(abs(x)^2)^1/2*
|
44 | *
|
45 | * @param axis Optional. If axis is null (the default), the input is
|
46 | * considered a vector and a single vector norm is computed over the entire
|
47 | * set of values in the Tensor, i.e. norm(x, ord) is equivalent
|
48 | * to norm(x.reshape([-1]), ord). If axis is a integer, the input
|
49 | * is considered a batch of vectors, and axis determines the axis in x
|
50 | * over which to compute vector norms. If axis is a 2-tuple of integer it is
|
51 | * considered a batch of matrices and axis determines the axes in NDArray
|
52 | * over which to compute a matrix norm.
|
53 | * @param keepDims Optional. If true, the norm have the same dimensionality
|
54 | * as the input.
|
55 | *
|
56 | * @doc {heading: 'Operations', subheading: 'Matrices'}
|
57 | */
|
58 | declare function norm_(x: Tensor | TensorLike, ord?: number | 'euclidean' | 'fro', axis?: number | number[], keepDims?: boolean): Tensor;
|
59 | export declare const norm: typeof norm_;
|
60 | export {};
|