UNPKG

2.17 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 */
17import { Tensor } from '../tensor';
18import { TensorLike } from '../types';
19/**
20 * Pads a `tf.Tensor` using mirror padding.
21 *
22 * This operation implements the `REFLECT` and `SYMMETRIC` modes of pad.
23 *
24 * ```js
25 * const x = tf.range(0, 9).reshape([1, 1, 3, 3]);
26 * x.mirrorPad([[0, 0], [0, 0], [2, 2], [2, 2]], 'reflect').print();
27 * ```
28 * @param x The tensor to pad.
29 * @param paddings An array of length `R` (the rank of the tensor), where
30 * each element is a length-2 tuple of ints `[padBefore, padAfter]`,
31 * specifying how much to pad along each dimension of the tensor.
32 * In "reflect" mode, the padded regions do not include the borders,
33 * while in "symmetric" mode the padded regions do include the borders.
34 * For example, if the input is `[1, 2, 3]` and paddings is `[0, 2]`,
35 * then the output is `[1, 2, 3, 2, 1]` in "reflect" mode, and
36 * `[1, 2, 3, 3, 2]` in "symmetric" mode.
37 * If `mode` is "reflect" then both `paddings[D, 0]` and `paddings[D, 1]`
38 * must be no greater than `x.shape[D] - 1`. If mode is "symmetric"
39 * then both `paddings[D, 0]` and `paddings[D, 1]` must be no greater than
40 * `x.shape[D]`
41 * @param mode String to specify padding mode. Can be `'reflect' | 'symmetric'`
42 */
43/** @doc {heading: 'Tensors', subheading: 'Transformations'} */
44declare function mirrorPad_<T extends Tensor>(x: T | TensorLike, paddings: Array<[number, number]>, mode: 'reflect' | 'symmetric'): T;
45export declare const mirrorPad: typeof mirrorPad_;
46export {};