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

Function conv2d_v2

tensorflow/python/ops/nn_ops.py:1875–1955  ·  view source on GitHub ↗

r"""Computes a 2-D convolution given 4-D `input` and `filters` tensors. Given an input tensor of shape `[batch, in_height, in_width, in_channels]` and a filter / kernel tensor of shape `[filter_height, filter_width, in_channels, out_channels]`, this op performs the following: 1. Flattens

(input,  # pylint: disable=redefined-builtin
              filters,
              strides,
              padding,
              data_format="NHWC",
              dilations=None,
              name=None)

Source from the content-addressed store, hash-verified

1873
1874@tf_export("nn.conv2d", v1=[])
1875def conv2d_v2(input, # pylint: disable=redefined-builtin
1876 filters,
1877 strides,
1878 padding,
1879 data_format="NHWC",
1880 dilations=None,
1881 name=None):
1882 # pylint: disable=line-too-long
1883 r"""Computes a 2-D convolution given 4-D `input` and `filters` tensors.
1884
1885 Given an input tensor of shape `[batch, in_height, in_width, in_channels]`
1886 and a filter / kernel tensor of shape
1887 `[filter_height, filter_width, in_channels, out_channels]`, this op
1888 performs the following:
1889
1890 1. Flattens the filter to a 2-D matrix with shape
1891 `[filter_height * filter_width * in_channels, output_channels]`.
1892 2. Extracts image patches from the input tensor to form a *virtual*
1893 tensor of shape `[batch, out_height, out_width,
1894 filter_height * filter_width * in_channels]`.
1895 3. For each patch, right-multiplies the filter matrix and the image patch
1896 vector.
1897
1898 In detail, with the default NHWC format,
1899
1900 output[b, i, j, k] =
1901 sum_{di, dj, q} input[b, strides[1] * i + di, strides[2] * j + dj, q] *
1902 filter[di, dj, q, k]
1903
1904 Must have `strides[0] = strides[3] = 1`. For the most common case of the same
1905 horizontal and vertices strides, `strides = [1, stride, stride, 1]`.
1906
1907 Args:
1908 input: A `Tensor`. Must be one of the following types:
1909 `half`, `bfloat16`, `float32`, `float64`.
1910 A 4-D tensor. The dimension order is interpreted according to the value
1911 of `data_format`, see below for details.
1912 filters: A `Tensor`. Must have the same type as `input`.
1913 A 4-D tensor of shape
1914 `[filter_height, filter_width, in_channels, out_channels]`
1915 strides: An int or list of `ints` that has length `1`, `2` or `4`. The
1916 stride of the sliding window for each dimension of `input`. If a single
1917 value is given it is replicated in the `H` and `W` dimension. By default
1918 the `N` and `C` dimensions are set to 1. The dimension order is determined
1919 by the value of `data_format`, see below for details.
1920 padding: Either the `string` `"SAME"` or `"VALID"` indicating the type of
1921 padding algorithm to use, or a list indicating the explicit paddings at
1922 the start and end of each dimension. When explicit padding is used and
1923 data_format is `"NHWC"`, this should be in the form `[[0, 0], [pad_top,
1924 pad_bottom], [pad_left, pad_right], [0, 0]]`. When explicit padding used
1925 and data_format is `"NCHW"`, this should be in the form `[[0, 0], [0, 0],
1926 [pad_top, pad_bottom], [pad_left, pad_right]]`.
1927 data_format: An optional `string` from: `"NHWC", "NCHW"`.
1928 Defaults to `"NHWC"`.
1929 Specify the data format of the input and output data. With the
1930 default format "NHWC", the data is stored in the order of:
1931 [batch, height, width, channels].
1932 Alternatively, the format could be "NCHW", the data storage order of:

Callers

nothing calls this directly

Calls 1

conv2dFunction · 0.70

Tested by

no test coverage detected