Conv2D
tensorflow C++ API
Addsbias
tovalue
.
Summary
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:
- Flattens the filter to a 2-D matrix with shape
[filter_height * filter_width * in_channels, output_channels]
. - Extracts image patches from the input tensor to form a
virtual
tensor of shape
[batch, out_height, out_width, filter_height * filter_width * in_channels]
. - For each patch, right-multiplies the filter matrix and the image patch vector.
In detail, with the default NHWC format,
output[b, i, j, k]=
sum_{di, dj, q} input[b, strides[1]* i + di, strides[2]* j + dj, q]*
filter[di, dj, q, k]
Must havestrides[0] = strides[3] = 1
. For the most common case of the same horizontal and vertices strides,strides = [1, stride, stride, 1]
.
Arguments:
- scope: A Scope object
- input: A 4-D tensor. The dimension order is interpreted according to the value of
data_format
, see below for details. - filter: A 4-D tensor of shape
[filter_height, filter_width, in_channels, out_channels]
- strides: 1-D tensor of length 4. The stride of the sliding window for each dimension of
input
. The dimension order is determined by the value ofdata_format
, see below for details. - padding: The type of padding algorithm to use.
Optional attributes (seeAttrs
):
- data_format: Specify the data format of the input and output data. With the default format "NHWC", the data is stored in the order of: [batch, height, width, channels]. Alternatively, the format could be "NCHW", the data storage order of: [batch, channels, height, width].
Returns:
Output
: A 4-D tensor. The dimension order is determined by the value ofdata_format
, see below for details.
Conv2D block
Source link : https://github.com/EXPNUNI/enuSpaceTensorflow/blob/master/enuSpaceTensorflow/tf_nn.cpp
Argument:
- Scope scope : A Scope object (A scope is generated automatically each page. A scope is not connected.)
- Input input: connect Input node.
- Input filter: connect Input node.
- gtl::ArraySlice< int > strides: Input strides in value ex)1,2,2,1
- StringPiece padding: Input paddingin value ex)SAME
- Conv2D ::Attrs attrs : Input attrs in value. ex) use_cudnn_on_gpu_ = true;data_format_ = NHWC;
Return:
- Output output : Output object of Conv2D class object.
Result:
- std::vector(Tensor) result_output : Returned object of executed result by calling session.