UNPKG

1.92 kBTypeScriptView Raw
1/**
2 * @license
3 * Copyright 2020 Google Inc. 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/mean" />
18import { Tensor } from '../tensor';
19import { TensorLike } from '../types';
20/**
21 * Computes the mean of elements across dimensions of a `tf.Tensor`.
22 *
23 * Reduces `x` along the dimensions given in `axis`. Unless `keepDims` is
24 * true, the rank of the `tf.Tensor` 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 a `tf.Tensor` with
27 * a single element is returned.
28 *
29 * ```js
30 * const x = tf.tensor1d([1, 2, 3]);
31 *
32 * x.mean().print(); // or tf.mean(a)
33 * ```
34 *
35 * ```js
36 * const x = tf.tensor2d([1, 2, 3, 4], [2, 2]);
37 *
38 * const axis = 1;
39 * x.mean(axis).print(); // or tf.mean(x, axis)
40 * ```
41 *
42 * @param x The input tensor.
43 * @param axis The dimension(s) to reduce. By default it reduces
44 * all dimensions.
45 * @param keepDims If true, retains reduced dimensions with size 1.
46 *
47 * @doc {heading: 'Operations', subheading: 'Reduction'}
48 */
49declare function mean_<T extends Tensor>(x: Tensor | TensorLike, axis?: number | number[], keepDims?: boolean): T;
50export declare const mean: typeof mean_;
51export {};