UNPKG

2.91 kBTypeScriptView Raw
1/// <amd-module name="@tensorflow/tfjs-core/dist/ops/depthwise_conv2d" />
2import { Tensor3D, Tensor4D } from '../tensor';
3import { TensorLike } from '../types';
4import { ExplicitPadding } from './conv_util';
5/**
6 * Depthwise 2D convolution.
7 *
8 * Given a 4D `input` array and a `filter` array of shape
9 * `[filterHeight, filterWidth, inChannels, channelMultiplier]` containing
10 * `inChannels` convolutional filters of depth 1, this op applies a
11 * different filter to each input channel (expanding from 1 channel to
12 * `channelMultiplier` channels for each), then concatenates the results
13 * together. The output has `inChannels * channelMultiplier` channels.
14 *
15 * See
16 * [https://www.tensorflow.org/api_docs/python/tf/nn/depthwise_conv2d](
17 * https://www.tensorflow.org/api_docs/python/tf/nn/depthwise_conv2d)
18 * for more details.
19 *
20 * @param x The input tensor, of rank 4 or rank 3, of shape
21 * `[batch, height, width, inChannels]`. If rank 3, batch of 1 is
22 * assumed.
23 * @param filter The filter tensor, rank 4, of shape
24 * `[filterHeight, filterWidth, inChannels, channelMultiplier]`.
25 * @param strides The strides of the convolution: `[strideHeight,
26 * strideWidth]`. If strides is a single number, then `strideHeight ==
27 * strideWidth`.
28 * @param pad The type of padding algorithm.
29 * - `same` and stride 1: output will be of same size as input,
30 * regardless of filter size.
31 * - `valid`: output will be smaller than input if filter is larger
32 * than 1x1.
33 * - For more info, see this guide:
34 * [https://www.tensorflow.org/api_docs/python/tf/nn/convolution](
35 * https://www.tensorflow.org/api_docs/python/tf/nn/convolution)
36 * @param dilations The dilation rates: `[dilationHeight, dilationWidth]`
37 * in which we sample input values across the height and width dimensions
38 * in atrous convolution. Defaults to `[1, 1]`. If `rate` is a single
39 * number, then `dilationHeight == dilationWidth`. If it is greater than
40 * 1, then all values of `strides` must be 1.
41 * @param dataFormat: An optional string from: "NHWC", "NCHW". Defaults to
42 * "NHWC". Specify the data format of the input and output data. With the
43 * default format "NHWC", the data is stored in the order of: [batch,
44 * height, width, channels]. Only "NHWC" is currently supported.
45 * @param dimRoundingMode A string from: 'ceil', 'round', 'floor'. If none is
46 * provided, it will default to truncate.
47 *
48 * @doc {heading: 'Operations', subheading: 'Convolution'}
49 */
50declare function depthwiseConv2d_<T extends Tensor3D | Tensor4D>(x: T | TensorLike, filter: Tensor4D | TensorLike, strides: [number, number] | number, pad: 'valid' | 'same' | number | ExplicitPadding, dataFormat?: 'NHWC' | 'NCHW', dilations?: [number, number] | number, dimRoundingMode?: 'floor' | 'round' | 'ceil'): T;
51export declare const depthwiseConv2d: typeof depthwiseConv2d_;
52export {};