Analysis of tf.nn.conv2d(xxx) and tf.nn.max_pool(xxx) of tf

I originally planned to read the blog to learn, but the writing on Baidu is not clear, so I found that it is better to read the official API, which is very detailed, relatively speaking.

So in the future, I still recommend everyone to read the official documents. Although it may be a bit inconsistent with English, it is actually normal, and the words written by others are also very common English words.

And I also realized that learning Python is a bit biased. Function knowledge is still well written in the official API, which is faster than Baidu's half-day.

conv2d(

    input, #input data
    filter, #convolution kernel
    strides, #step size
    padding, #whether padding around 0
    use_cudnn_on_gpu=True,
    data_format='NHWC',
    name=None
)
 2-dimensional convolution calculation, given input and filter parameters All are 4-dimensional tensors.
Return:
The same 4-dimensional tensor as the input parameter. . The order between the 4 dimensions is determined by the value of the parameter data_format.  
 
input tensor of shape [ batch , in_height, in_width,   in_channels ]  
filter tensor of shape [filter_height, filter_width, in_channels , out_channels]
Flattens the filter to a 2-D matrix with shape [filter_height * filter_width * in_channels, output_channels].
For each patch, right-multiplies the filter matrix and the image patch vector
最终返回输出的4维张量: [ batch , out_height, out_width , out_channel ]
 
strides: 元素长度为4的list,类型为int.Must have strides[0] = strides[3] = 1. strides = [1, stride, stride, 1].
padding: A string from: "SAME", "VALID".
if padding=‘SAME’ 
   out_height=out_width= (in_height=in_width)/stride
else out_height=out_width= ((in_height=in_width)-(filter_height=filter_width)+1)/stride
 
use_cudnn_on_gpu: An optional bool. Defaults to True.
data_format: An optional string from: "NHWC", "NCHW". 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].

name: A name for the operation (optional).


max_pool(
    value,
    ksize,
    strides,
    padding,
    data_format='NHWC',
    name=None
)
performs max pooling calculation on input data
Returns:
A Tensor of format specified by data_format. The max pooled output tensor.
 
    value: A 4-D Tensor of the format specified by data_format.
    ksize: a list with an element length of 4, the type is int. Indicates the size of the pooling kernel
    strides: a list with an element length of 4, the type is int. Indicates the pooling step size
    padding: A string , either 'VALID' or 'SAME'. As defined above
    data_format: A string. 'NHWC', 'NCHW' and 'NCHW_VECT_C' are supported.
    name: Optional name for the operation.
 

Must have strides = [1, stride, stride, 1]. 

                ksizes = [1, ksize, ksize, 1]. 

          

Guess you like

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