UNPKG

2.61 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/max_pool" />
18import { Tensor3D, Tensor4D } from '../tensor';
19import { TensorLike } from '../types';
20import * as conv_util from './conv_util';
21/**
22 * Computes the 2D max pooling of an image.
23 *
24 * @param x The input tensor, of rank 4 or rank 3 of shape
25 * `[batch, height, width, inChannels]`. If rank 3, batch of 1 is assumed.
26 * @param filterSize The filter size: `[filterHeight, filterWidth]`. If
27 * `filterSize` is a single number, then `filterHeight == filterWidth`.
28 * @param strides The strides of the pooling: `[strideHeight, strideWidth]`. If
29 * `strides` is a single number, then `strideHeight == strideWidth`.
30 * @param dilations The dilation rates: `[dilationHeight, dilationWidth]`
31 * in which we sample input values across the height and width dimensions
32 * in dilated pooling. Defaults to `[1, 1]`. If `dilations` is a single
33 * number, then `dilationHeight == dilationWidth`. If it is greater than
34 * 1, then all values of `strides` must be 1.
35 * @param pad The type of padding algorithm.
36 * - `same` and stride 1: output will be of same size as input,
37 * regardless of filter size.
38 * - `valid`: output will be smaller than input if filter is larger
39 * than 1x1.
40 * - For more info, see this guide:
41 * [https://www.tensorflow.org/api_docs/python/tf/nn/convolution](
42 * https://www.tensorflow.org/api_docs/python/tf/nn/convolution)
43 * @param dimRoundingMode A string from: 'ceil', 'round', 'floor'. If none is
44 * provided, it will default to truncate.
45 */
46declare function maxPool_<T extends Tensor3D | Tensor4D>(x: T | TensorLike, filterSize: [number, number] | number, strides: [number, number] | number, pad: 'valid' | 'same' | number | conv_util.ExplicitPadding, dimRoundingMode?: 'floor' | 'round' | 'ceil'): T;
47export declare const maxPool: typeof maxPool_;
48export {};