tf的tf.nn.conv2d(xxx)和tf.nn.max_pool(xxx)解析

本来打算看博客学习,可是百度上的写的不清晰,所以发现还是看官方API写的好,很详细,相对来说吧。

所以以后还是建议大伙去看官方文档,尽管可能有点抵触英语,其实也一般般啦,人家写的也是很常见的英语单词。

而且自己也体会到,学Python有些比较偏的,函数知识,还是官方API写的好,比自己百度半天来的快。

conv2d(

    input, #输入数据
    filter, #卷积核
    strides, #步长
    padding, #是否周围填充0
    use_cudnn_on_gpu=True,
    data_format='NHWC',
    name=None
)
 2维卷积计算, 给定的 input and filter 参数 都是4维张量.
返回:
和input参数一样的4维张量. . 4个维度间的顺序是由参数 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
)
对输入数据进行最大池化计算
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: 元素长度为4的list,类型为int.表示池化核的尺寸大小
    strides: 元素长度为4的list,类型为int.表示池化步长
    padding: A string, either 'VALID' or 'SAME'. 同上面定义
    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]. 

          

猜你喜欢

转载自blog.csdn.net/fu6543210/article/details/80085781
今日推荐