UNPKG

1.99 kBTypeScriptView Raw
1/**
2 * @license
3 * Copyright 2020 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/log_sum_exp" />
18import { Tensor } from '../tensor';
19import { TensorLike } from '../types';
20/**
21 * Computes the log(sum(exp(elements across the reduction dimensions)).
22 *
23 * Reduces the input along the dimensions given in `axis`. Unless `keepDims`
24 * is true, the rank of the array is reduced by 1 for each entry in `axis`.
25 * If `keepDims` is true, the reduced dimensions are retained with length 1.
26 * If `axis` has no entries, all dimensions are reduced, and an array with a
27 * single element is returned.
28 *
29 * ```js
30 * const x = tf.tensor1d([1, 2, 3]);
31 *
32 * x.logSumExp().print(); // or tf.logSumExp(x)
33 * ```
34 *
35 * ```js
36 * const x = tf.tensor2d([1, 2, 3, 4], [2, 2]);
37 *
38 * const axis = 1;
39 * x.logSumExp(axis).print(); // or tf.logSumExp(a, axis)
40 * ```
41 * @param x The input tensor.
42 * @param axis The dimension(s) to reduce. If null (the default),
43 * reduces all dimensions.
44 * @param keepDims If true, retains reduced dimensions with length
45 * of 1. Defaults to false.
46 *
47 * @doc {heading: 'Operations', subheading: 'Reduction'}
48 */
49declare function logSumExp_<T extends Tensor>(x: Tensor | TensorLike, axis?: number | number[], keepDims?: boolean): T;
50export declare const logSumExp: typeof logSumExp_;
51export {};