UNPKG

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