Tensorflow function and parameter description

Address of this article:

1 tf.nn.conv2d

tf.nn.conv2d(input, filter, strides, padding, use_cudnn_on_gpu=None, name=None)

The first parameter input: refers to the input image that needs to be convolved. It requires a Tensor with a shape of [batch, in_height, in_width,
in_channels]. The specific meaning is [the number of images in a batch during training, image height, Image width,
number of image channels], note that this is a 4-dimensional Tensor, which requires one of float32 and float64 The
second parameter filter: equivalent to the convolution kernel in CNN, it requires a Tensor with [filter_height , filter_width,
in_channels, out_channels], the specific meaning is [the height of the convolution kernel, the width of the convolution kernel, the number of image channels, the number of convolution kernels], the required type is the same as the parameter input, and the number of channels of the filter is required. Consistent with the in_channels of the input, there is one thing to pay attention to. The third dimension in_channels is the fourth dimension of the parameter input. The
third parameter strides: the step size of each dimension of the image during convolution, which is a one-dimensional vector with length 4. strides[0]=strides[3]=1
The fourth parameter padding: the amount of string type, which can only be one of "SAME" and "VALID". This value determines different convolution methods (will be discussed later Introduction)
The fifth parameter: use_cudnn_on_gpu: bool type, whether to use cudnn acceleration, the default is true.
The result returns a Tensor. This output is the sixth parameter of the feature map we often say : different padding methods, VALID is the method of discarding, the method of SAME, and the left and right are filled with zeros.
For the SAME padding, the output height and width are computed as:
out_height = ceil(float(in_height) / float(strides[1]))
out_width = ceil(float(in_width) / float(strides[2]))
For the VALID padding, the output height and width are computed as:
out_height = ceil(float(in_height - filter_height + 1) / float(strides[1]))
out_width = ceil(float(in_width - filter_width + 1) / float(strides[2]))

2

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324817312&siteId=291194637