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

Function depthwise_conv2d_v2

tensorflow/python/ops/nn_impl.py:922–976  ·  view source on GitHub ↗

Depthwise 2-D convolution. 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,
                        filter,
                        strides,
                        padding,
                        data_format=None,
                        dilations=None,
                        name=None)

Source from the content-addressed store, hash-verified

920
921@tf_export("nn.depthwise_conv2d", v1=[])
922def depthwise_conv2d_v2(input,
923 filter,
924 strides,
925 padding,
926 data_format=None,
927 dilations=None,
928 name=None):
929 """Depthwise 2-D convolution.
930
931 Given a 4D input tensor ('NHWC' or 'NCHW' data formats)
932 and a filter tensor of shape
933 `[filter_height, filter_width, in_channels, channel_multiplier]`
934 containing `in_channels` convolutional filters of depth 1, `depthwise_conv2d`
935 applies a different filter to each input channel (expanding from 1 channel
936 to `channel_multiplier` channels for each), then concatenates the results
937 together. The output has `in_channels * channel_multiplier` channels.
938
939 In detail, with the default NHWC format,
940
941 output[b, i, j, k * channel_multiplier + q] = sum_{di, dj}
942 filter[di, dj, k, q] * input[b, strides[1] * i + rate[0] * di,
943 strides[2] * j + rate[1] * dj, k]
944
945 Must have `strides[0] = strides[3] = 1`. For the most common case of the
946 same horizontal and vertical strides, `strides = [1, stride, stride, 1]`.
947 If any value in `rate` is greater than 1, we perform atrous depthwise
948 convolution, in which case all values in the `strides` tensor must be equal
949 to 1.
950
951 Args:
952 input: 4-D with shape according to `data_format`.
953 filter: 4-D with shape
954 `[filter_height, filter_width, in_channels, channel_multiplier]`.
955 strides: 1-D of size 4. The stride of the sliding window for each
956 dimension of `input`.
957 padding: A string, either `'VALID'` or `'SAME'`. The padding algorithm.
958 See the "returns" section of `tf.nn.convolution` for details.
959 data_format: The data format for input. Either "NHWC" (default) or "NCHW".
960 dilations: 1-D of size 2. The dilation rate in which we sample input values
961 across the `height` and `width` dimensions in atrous convolution. If it is
962 greater than 1, then all values of strides must be 1.
963 name: A name for this operation (optional).
964
965 Returns:
966 A 4-D `Tensor` with shape according to `data_format`. E.g., for
967 "NHWC" format, shape is
968 `[batch, out_height, out_width, in_channels * channel_multiplier].`
969 """
970 return depthwise_conv2d(input=input,
971 filter=filter,
972 strides=strides,
973 padding=padding,
974 rate=dilations,
975 name=name,
976 data_format=data_format)
977
978# pylint: enable=redefined-builtin
979

Callers

nothing calls this directly

Calls 1

depthwise_conv2dFunction · 0.70

Tested by

no test coverage detected