tf.nn.separable_conv2d
Stay organized with collections
Save and categorize content based on your preferences.
2-D convolution with separable filters.
tf.nn.separable_conv2d(
input,
depthwise_filter,
pointwise_filter,
strides,
padding,
data_format=None,
dilations=None,
name=None
)
Performs a depthwise convolution that acts separately on channels followed by
a pointwise convolution that mixes channels. Note that this is separability
between dimensions [1, 2]
and 3
, not spatial separability between
dimensions 1
and 2
.
In detail, with the default NHWC format,
output[b, i, j, k] = sum_{di, dj, q, r}
input[b, strides[1] * i + di, strides[2] * j + dj, q] *
depthwise_filter[di, dj, q, r] *
pointwise_filter[0, 0, q * channel_multiplier + r, k]
strides
controls the strides for the depthwise convolution only, since
the pointwise convolution has implicit strides of [1, 1, 1, 1]
. 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 Tensor with shape according to data_format .
|
depthwise_filter
|
4-D Tensor with shape [filter_height, filter_width,
in_channels, channel_multiplier] . Contains in_channels convolutional
filters of depth 1.
|
pointwise_filter
|
4-D Tensor with shape [1, 1, channel_multiplier *
in_channels, out_channels] . Pointwise filter to mix channels after
depthwise_filter has convolved spatially.
|
strides
|
1-D of size 4. The strides for the depthwise convolution for each
dimension of input .
|
padding
|
Controls how to pad the image before applying the depthwise
convolution. Can be the string "SAME" or "VALID" indicating the type
of padding algorithm to use, or a Python list indicating the explicit
paddings at the start and end of each dimension. When explicit padding is
used and data_format is "NHWC" , this should be in the form [[0, 0],
[pad_top, pad_bottom], [pad_left, pad_right], [0, 0]] . When explicit
padding used and data_format is "NCHW" , this should be in the form
[[0, 0], [0, 0], [pad_top, pad_bottom], [pad_left, pad_right]] .
|
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'. For
example, with data_format="NHWC", shape is [batch, out_height,
out_width, out_channels].
|
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. Some content is licensed under the numpy license.
Last updated 2024-04-26 UTC.
[null,null,["Last updated 2024-04-26 UTC."],[],[],null,["# tf.nn.separable_conv2d\n\n\u003cbr /\u003e\n\n|-----------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.16.1/tensorflow/python/ops/nn_impl.py#L1001-L1072) |\n\n2-D convolution with separable filters. \n\n tf.nn.separable_conv2d(\n input,\n depthwise_filter,\n pointwise_filter,\n strides,\n padding,\n data_format=None,\n dilations=None,\n name=None\n )\n\nPerforms a depthwise convolution that acts separately on channels followed by\na pointwise convolution that mixes channels. Note that this is separability\nbetween dimensions `[1, 2]` and `3`, not spatial separability between\ndimensions `1` and `2`.\n\nIn detail, with the default NHWC format, \n\n output[b, i, j, k] = sum_{di, dj, q, r}\n input[b, strides[1] * i + di, strides[2] * j + dj, q] *\n depthwise_filter[di, dj, q, r] *\n pointwise_filter[0, 0, q * channel_multiplier + r, k]\n\n`strides` controls the strides for the depthwise convolution only, since\nthe pointwise convolution has implicit strides of `[1, 1, 1, 1]`. Must have\n`strides[0] = strides[3] = 1`. For the most common case of the same\nhorizontal 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 `Tensor` with shape according to `data_format`. |\n| `depthwise_filter` | 4-D `Tensor` with shape `[filter_height, filter_width, in_channels, channel_multiplier]`. Contains `in_channels` convolutional filters of depth 1. |\n| `pointwise_filter` | 4-D `Tensor` with shape `[1, 1, channel_multiplier * in_channels, out_channels]`. Pointwise filter to mix channels after `depthwise_filter` has convolved spatially. |\n| `strides` | 1-D of size 4. The strides for the depthwise convolution for each dimension of `input`. |\n| `padding` | Controls how to pad the image before applying the depthwise convolution. Can be the string `\"SAME\"` or `\"VALID\"` indicating the type of padding algorithm to use, or a Python list indicating the explicit paddings at the start and end of each dimension. When explicit padding is used and data_format is `\"NHWC\"`, this should be in the form `[[0, 0], [pad_top, pad_bottom], [pad_left, pad_right], [0, 0]]`. When explicit padding used and data_format is `\"NCHW\"`, this should be in the form `[[0, 0], [0, 0], [pad_top, pad_bottom], [pad_left, pad_right]]`. |\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'. For example, with data_format=\"NHWC\", shape is \\[batch, out_height, out_width, out_channels\\]. ||\n\n\u003cbr /\u003e"]]