UNPKG

2.04 kBTypeScriptView Raw
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 */
17import { Scalar, Tensor } from '../tensor';
18import { TensorLike } from '../types';
19/**
20 * Compute the moving average of a variable.
21 *
22 * Without zeroDebias, the moving average operation is defined by:
23 * `v += delta`
24 * where
25 * `delta = (1 - decay) * (x - v)`
26 *
27 * With zeroDebias (default), the `delta` term is scaled to debias the
28 * effect of the (assumed) zero-initialization of `v`.
29 * `delta /= (1 - decay ^ step)`
30 *
31 * For more details on the zero-debiasing algorithm, see:
32 * https://arxiv.org/abs/1412.6980
33 *
34 * Note that this function is completely stateless and does not keep track of
35 * step count. The step count needs to be maintained by the caller and passed
36 * in as `step`.
37 *
38 * @param v The current moving average value.
39 * @param x New input value, must have the same shape and dtype as `v`.
40 * @param decay The decay factor. Typical values are 0.95 and 0.99.
41 * @param step Step count.
42 * @param zeroDebias: Whether zeroDebias is to be performed (default: `true`).
43 * @returns The new moving average value.
44 *
45 * @doc {heading: 'Operations', subheading: 'Moving Average'}
46 */
47declare function movingAverage_<T extends Tensor>(v: T | TensorLike, x: T | TensorLike, decay: number | Scalar, step?: number | Scalar, zeroDebias?: boolean): T;
48export declare const movingAverage: typeof movingAverage_;
49export {};