MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / separable_conv2d

Function separable_conv2d

tensorflow/python/ops/nn_impl.py:983–1080  ·  view source on GitHub ↗

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,
                     rate=None,
                     name=None,
                     data_format=None,
                     dilations=None)

Source from the content-addressed store, hash-verified

981# pylint: disable=redefined-builtin,line-too-long
982@tf_export(v1=["nn.separable_conv2d"])
983def separable_conv2d(input,
984 depthwise_filter,
985 pointwise_filter,
986 strides,
987 padding,
988 rate=None,
989 name=None,
990 data_format=None,
991 dilations=None):
992 """2-D convolution with separable filters.
993
994 Performs a depthwise convolution that acts separately on channels followed by
995 a pointwise convolution that mixes channels. Note that this is separability
996 between dimensions `[1, 2]` and `3`, not spatial separability between
997 dimensions `1` and `2`.
998
999 In detail, with the default NHWC format,
1000
1001 output[b, i, j, k] = sum_{di, dj, q, r}
1002 input[b, strides[1] * i + di, strides[2] * j + dj, q] *
1003 depthwise_filter[di, dj, q, r] *
1004 pointwise_filter[0, 0, q * channel_multiplier + r, k]
1005
1006 `strides` controls the strides for the depthwise convolution only, since
1007 the pointwise convolution has implicit strides of `[1, 1, 1, 1]`. Must have
1008 `strides[0] = strides[3] = 1`. For the most common case of the same
1009 horizontal and vertical strides, `strides = [1, stride, stride, 1]`.
1010 If any value in `rate` is greater than 1, we perform atrous depthwise
1011 convolution, in which case all values in the `strides` tensor must be equal
1012 to 1.
1013
1014 Args:
1015 input: 4-D `Tensor` with shape according to `data_format`.
1016 depthwise_filter: 4-D `Tensor` with shape
1017 `[filter_height, filter_width, in_channels, channel_multiplier]`.
1018 Contains `in_channels` convolutional filters of depth 1.
1019 pointwise_filter: 4-D `Tensor` with shape
1020 `[1, 1, channel_multiplier * in_channels, out_channels]`. Pointwise
1021 filter to mix channels after `depthwise_filter` has convolved spatially.
1022 strides: 1-D of size 4. The strides for the depthwise convolution for
1023 each dimension of `input`.
1024 padding: A string, either `'VALID'` or `'SAME'`. The padding algorithm.
1025 See the "returns" section of `tf.nn.convolution` for details.
1026 rate: 1-D of size 2. The dilation rate in which we sample input values
1027 across the `height` and `width` dimensions in atrous convolution. If it is
1028 greater than 1, then all values of strides must be 1.
1029 name: A name for this operation (optional).
1030 data_format: The data format for input. Either "NHWC" (default) or "NCHW".
1031 dilations: Alias of rate.
1032
1033 Returns:
1034 A 4-D `Tensor` with shape according to 'data_format'. For
1035 example, with data_format="NHWC", shape is [batch, out_height,
1036 out_width, out_channels].
1037 """
1038 rate = deprecated_argument_lookup("dilations", dilations, "rate", rate)
1039 with ops.name_scope(name, "separable_conv2d",
1040 [input, depthwise_filter, pointwise_filter]) as name:

Calls 6

with_rankMethod · 0.80
name_scopeMethod · 0.45
get_shapeMethod · 0.45
shapeMethod · 0.45