tf.nn.depthwise_conv2d
Stay organized with collections
Save and categorize content based on your preferences.
Depthwise 2-D convolution.
tf.nn.depthwise_conv2d(
input, filter, strides, padding, data_format=None, dilations=None, name=None
)
Given a 4D input tensor ('NHWC' or 'NCHW' data formats)
and a filter tensor of shape
[filter_height, filter_width, in_channels, channel_multiplier]
containing in_channels
convolutional filters of depth 1, depthwise_conv2d
applies a different filter to each input channel (expanding from 1 channel
to channel_multiplier
channels for each), then concatenates the results
together. The output has in_channels * channel_multiplier
channels.
In detail, with the default NHWC format,
output[b, i, j, k * channel_multiplier + q] = sum_{di, dj}
filter[di, dj, k, q] * input[b, strides[1] * i + rate[0] * di,
strides[2] * j + rate[1] * dj, k]
Must have strides[0] = strides[3] = 1
. For the most common case of the
same horizontal and vertical strides, strides = [1, stride, stride, 1]
.
If any value in rate
is greater than 1, we perform atrous depthwise
convolution, in which case all values in the strides
tensor must be equal
to 1.
Args |
input
|
4-D with shape according to data_format .
|
filter
|
4-D with shape
[filter_height, filter_width, in_channels, channel_multiplier] .
|
strides
|
1-D of size 4. The stride of the sliding window for each
dimension of input .
|
padding
|
A string, either 'VALID' or 'SAME' . The padding algorithm.
See the "returns" section of tf.nn.convolution for details.
|
data_format
|
The data format for input. Either "NHWC" (default) or "NCHW".
|
dilations
|
1-D of size 2. The dilation rate in which we sample input values
across the height and width dimensions in atrous convolution. If it is
greater than 1, then all values of strides must be 1.
|
name
|
A name for this operation (optional).
|
Returns |
A 4-D Tensor with shape according to data_format . E.g., for
"NHWC" format, shape is
[batch, out_height, out_width, in_channels * channel_multiplier].
|
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2020-10-01 UTC.
[null,null,["Last updated 2020-10-01 UTC."],[],[],null,["# tf.nn.depthwise_conv2d\n\n\u003cbr /\u003e\n\n|--------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------|\n| [TensorFlow 1 version](/versions/r1.15/api_docs/python/tf/nn/depthwise_conv2d) | [View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.0.0/tensorflow/python/ops/nn_impl.py#L830-L885) |\n\nDepthwise 2-D convolution. \n\n tf.nn.depthwise_conv2d(\n input, filter, strides, padding, data_format=None, dilations=None, name=None\n )\n\nGiven a 4D input tensor ('NHWC' or 'NCHW' data formats)\nand a filter tensor of shape\n`[filter_height, filter_width, in_channels, channel_multiplier]`\ncontaining `in_channels` convolutional filters of depth 1, `depthwise_conv2d`\napplies a different filter to each input channel (expanding from 1 channel\nto `channel_multiplier` channels for each), then concatenates the results\ntogether. The output has `in_channels * channel_multiplier` channels.\n\nIn detail, with the default NHWC format, \n\n output[b, i, j, k * channel_multiplier + q] = sum_{di, dj}\n filter[di, dj, k, q] * input[b, strides[1] * i + rate[0] * di,\n strides[2] * j + rate[1] * dj, k]\n\nMust have `strides[0] = strides[3] = 1`. For the most common case of the\nsame horizontal and vertical strides, `strides = [1, stride, stride, 1]`.\nIf any value in `rate` is greater than 1, we perform atrous depthwise\nconvolution, in which case all values in the `strides` tensor must be equal\nto 1.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|---------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `input` | 4-D with shape according to `data_format`. |\n| `filter` | 4-D with shape `[filter_height, filter_width, in_channels, channel_multiplier]`. |\n| `strides` | 1-D of size 4. The stride of the sliding window for each dimension of `input`. |\n| `padding` | A string, either `'VALID'` or `'SAME'`. The padding algorithm. See the \"returns\" section of [`tf.nn.convolution`](../../tf/nn/convolution) for details. |\n| `data_format` | The data format for input. Either \"NHWC\" (default) or \"NCHW\". |\n| `dilations` | 1-D of size 2. The dilation rate in which we sample input values across the `height` and `width` dimensions in atrous convolution. If it is greater than 1, then all values of strides must be 1. |\n| `name` | A name for this operation (optional). |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ------- ||\n|---|---|\n| A 4-D `Tensor` with shape according to `data_format`. E.g., for \"NHWC\" format, shape is `[batch, out_height, out_width, in_channels * channel_multiplier].` ||\n\n\u003cbr /\u003e"]]