2-D convolution with separable filters. 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`.
(
input,
depthwise_filter,
pointwise_filter,
strides,
padding,
data_format=None,
dilations=None,
name=None,
)
| 1082 | |
| 1083 | @tf_export("nn.separable_conv2d", v1=[]) |
| 1084 | def separable_conv2d_v2( |
| 1085 | input, |
| 1086 | depthwise_filter, |
| 1087 | pointwise_filter, |
| 1088 | strides, |
| 1089 | padding, |
| 1090 | data_format=None, |
| 1091 | dilations=None, |
| 1092 | name=None, |
| 1093 | ): |
| 1094 | """2-D convolution with separable filters. |
| 1095 | |
| 1096 | Performs a depthwise convolution that acts separately on channels followed by |
| 1097 | a pointwise convolution that mixes channels. Note that this is separability |
| 1098 | between dimensions `[1, 2]` and `3`, not spatial separability between |
| 1099 | dimensions `1` and `2`. |
| 1100 | |
| 1101 | In detail, with the default NHWC format, |
| 1102 | |
| 1103 | output[b, i, j, k] = sum_{di, dj, q, r} |
| 1104 | input[b, strides[1] * i + di, strides[2] * j + dj, q] * |
| 1105 | depthwise_filter[di, dj, q, r] * |
| 1106 | pointwise_filter[0, 0, q * channel_multiplier + r, k] |
| 1107 | |
| 1108 | `strides` controls the strides for the depthwise convolution only, since |
| 1109 | the pointwise convolution has implicit strides of `[1, 1, 1, 1]`. Must have |
| 1110 | `strides[0] = strides[3] = 1`. For the most common case of the same |
| 1111 | horizontal and vertical strides, `strides = [1, stride, stride, 1]`. |
| 1112 | If any value in `rate` is greater than 1, we perform atrous depthwise |
| 1113 | convolution, in which case all values in the `strides` tensor must be equal |
| 1114 | to 1. |
| 1115 | |
| 1116 | Args: |
| 1117 | input: 4-D `Tensor` with shape according to `data_format`. |
| 1118 | depthwise_filter: 4-D `Tensor` with shape `[filter_height, filter_width, |
| 1119 | in_channels, channel_multiplier]`. Contains `in_channels` convolutional |
| 1120 | filters of depth 1. |
| 1121 | pointwise_filter: 4-D `Tensor` with shape `[1, 1, channel_multiplier * |
| 1122 | in_channels, out_channels]`. Pointwise filter to mix channels after |
| 1123 | `depthwise_filter` has convolved spatially. |
| 1124 | strides: 1-D of size 4. The strides for the depthwise convolution for each |
| 1125 | dimension of `input`. |
| 1126 | padding: A string, either `'VALID'` or `'SAME'`. The padding algorithm. See |
| 1127 | the "returns" section of `tf.nn.convolution` for details. |
| 1128 | data_format: The data format for input. Either "NHWC" (default) or "NCHW". |
| 1129 | dilations: 1-D of size 2. The dilation rate in which we sample input values |
| 1130 | across the `height` and `width` dimensions in atrous convolution. If it is |
| 1131 | greater than 1, then all values of strides must be 1. |
| 1132 | name: A name for this operation (optional). |
| 1133 | |
| 1134 | Returns: |
| 1135 | A 4-D `Tensor` with shape according to 'data_format'. For |
| 1136 | example, with data_format="NHWC", shape is [batch, out_height, |
| 1137 | out_width, out_channels]. |
| 1138 | """ |
| 1139 | return separable_conv2d( |
| 1140 | input, |
| 1141 | depthwise_filter, |
nothing calls this directly
no test coverage detected