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