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

Function conv2d

tensorflow/python/ops/nn_ops.py:1959–2052  ·  view source on GitHub ↗

r"""Computes a 2-D convolution given 4-D `input` and `filter` 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

(  # pylint: disable=redefined-builtin,dangerous-default-value
    input,
    filter=None,
    strides=None,
    padding=None,
    use_cudnn_on_gpu=True,
    data_format="NHWC",
    dilations=[1, 1, 1, 1],
    name=None,
    filters=None)

Source from the content-addressed store, hash-verified

1957
1958@tf_export(v1=["nn.conv2d"])
1959def conv2d( # pylint: disable=redefined-builtin,dangerous-default-value
1960 input,
1961 filter=None,
1962 strides=None,
1963 padding=None,
1964 use_cudnn_on_gpu=True,
1965 data_format="NHWC",
1966 dilations=[1, 1, 1, 1],
1967 name=None,
1968 filters=None):
1969 r"""Computes a 2-D convolution given 4-D `input` and `filter` tensors.
1970
1971 Given an input tensor of shape `[batch, in_height, in_width, in_channels]`
1972 and a filter / kernel tensor of shape
1973 `[filter_height, filter_width, in_channels, out_channels]`, this op
1974 performs the following:
1975
1976 1. Flattens the filter to a 2-D matrix with shape
1977 `[filter_height * filter_width * in_channels, output_channels]`.
1978 2. Extracts image patches from the input tensor to form a *virtual*
1979 tensor of shape `[batch, out_height, out_width,
1980 filter_height * filter_width * in_channels]`.
1981 3. For each patch, right-multiplies the filter matrix and the image patch
1982 vector.
1983
1984 In detail, with the default NHWC format,
1985
1986 output[b, i, j, k] =
1987 sum_{di, dj, q} input[b, strides[1] * i + di, strides[2] * j + dj, q]
1988 * filter[di, dj, q, k]
1989
1990 Must have `strides[0] = strides[3] = 1`. For the most common case of the same
1991 horizontal and vertices strides, `strides = [1, stride, stride, 1]`.
1992
1993 Args:
1994 input: A `Tensor`. Must be one of the following types:
1995 `half`, `bfloat16`, `float32`, `float64`.
1996 A 4-D tensor. The dimension order is interpreted according to the value
1997 of `data_format`, see below for details.
1998 filter: A `Tensor`. Must have the same type as `input`.
1999 A 4-D tensor of shape
2000 `[filter_height, filter_width, in_channels, out_channels]`
2001 strides: An int or list of `ints` that has length `1`, `2` or `4`. The
2002 stride of the sliding window for each dimension of `input`. If a single
2003 value is given it is replicated in the `H` and `W` dimension. By default
2004 the `N` and `C` dimensions are set to 1. The dimension order is determined
2005 by the value of `data_format`, see below for details.
2006 padding: Either the `string` `"SAME"` or `"VALID"` indicating the type of
2007 padding algorithm to use, or a list indicating the explicit paddings at
2008 the start and end of each dimension. When explicit padding is used and
2009 data_format is `"NHWC"`, this should be in the form `[[0, 0], [pad_top,
2010 pad_bottom], [pad_left, pad_right], [0, 0]]`. When explicit padding used
2011 and data_format is `"NCHW"`, this should be in the form `[[0, 0], [0, 0],
2012 [pad_top, pad_bottom], [pad_left, pad_right]]`.
2013 use_cudnn_on_gpu: An optional `bool`. Defaults to `True`.
2014 data_format: An optional `string` from: `"NHWC", "NCHW"`.
2015 Defaults to `"NHWC"`.
2016 Specify the data format of the input and output data. With the

Calls 2

_convert_paddingFunction · 0.85
_get_sequenceFunction · 0.70