tensorflow_conv2d_max_pool卷积池化padding参数为SAME和VALID的区别
2017-06-26 19:48
549 查看
卷积:conv2
In this example:
Input width = 13
Filter width = 6
Stride = 5
be an extra row of zeros at the bottom).
The
TensorFlow Convolution example gives an overview about the difference between
For the
out_height = ceil(float(in_height) / float(strides[1]))
out_width = ceil(float(in_width) / float(strides[2]))
And
For the
out_height = ceil(float(in_height - filter_height + 1) / float(strides[1]))
out_width = ceil(float(in_width - filter_width + 1) / float(strides[2]))
池化:max_pool
I'll give an example to make it clearer:
classic way to go)
The output shapes are:
"VALID"= without padding:
inputs: 1 2 3 4 5 6 7 8 9 10 11 (12 13) |________________| dropped |_________________|[/code]
"SAME"= with zero padding:
pad| |pad inputs: 0 |1 2 3 4 5 6 7 8 9 10 11 12 13|0 0 |________________| |_________________| |________________|[/code]
In this example:
Input width = 13
Filter width = 6
Stride = 5
"VALID"only ever drops the right-most columns (or bottom-most rows).
"SAME"tries to pad evenly left and right, but if the amount of columns to be added is odd, it will add the extra column to the right, as is the case in this example (the same logic applies vertically: there may
be an extra row of zeros at the bottom).
The
TensorFlow Convolution example gives an overview about the difference between
SAMEand
VALID:
For the
SAMEpadding, 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]))
And
For the
VALIDpadding, 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]))
池化:max_pool
I'll give an example to make it clearer:
x: input image of shape [2, 3], 1 channel
valid_pad: max pool with 2x2 kernel, stride 2 and VALID padding.
same_pad: max pool with 2x2 kernel, stride 2 and SAME padding (this is the
classic way to go)
The output shapes are:
valid_pad: here, no padding so the output shape is [1, 1]
same_pad: here, we pad the image to the shape [2, 4] (with
-infand then apply max pool), so the output shape is [1, 2]
x = tf.constant([[1., 2., 3.], [4., 5., 6.]]) x = tf.reshape(x, [1, 2, 3, 1]) # give a shape accepted by tf.nn.max_pool valid_pad = tf.nn.max_pool(x, [1, 2, 2, 1], [1, 2, 2, 1], padding='VALID') same_pad = tf.nn.max_pool(x, [1, 2, 2, 1], [1, 2, 2, 1], padding='SAME') valid_pad.get_shape() == [1, 1, 1, 1] # valid_pad is [5.] same_pad.get_shape() == [1, 1, 2, 1] # same_pad is [5., 6.][/code]
相关文章推荐
- [AI, 深度学习] tensorflow中padding="SAME"和"VALID"的区别
- padding参数为SAME和VALID的区别
- TensorFlow中padding的 'SAME' 和 'VALID' 参数
- Tensorflow中padding的两种类型SAME和VALID
- TensorFlow学习--SAME与VALID区别
- TensorFlow中CNN的两种padding方式“SAME”和“VALID”
- Tensorflow中padding的两种类型SAME和VALID
- TensorFlow中CNN的两种padding方式“SAME”和“VALID”
- Tensorflow中padding的两种类型SAME和VALID
- TensorFlow中CNN的两种padding方式“SAME”和“VALID”
- Tensorflow中padding的两种类型SAME和VALID
- tensorflow 中的padding方式“SAME”和“VALID”
- Tensorflow中padding的两种类型SAME和VALID
- Tensorflow里的padding操作(VALID和SAME两种)
- TensorFlow学习笔记(1)——conv2d函数的padding参数详解
- TensorFlow中CNN的两种padding方式“SAME”和“VALID”
- tf.nn.conv2d(input, filter, strides, padding, use_cudnn_on_gpu=None, name=None) 除去name参数用以指定该操作的nam
- tf.nn.conv3d和tf.nn.max_pool3d这两个tensorflow函数的功能和参数
- tensorflow:SAME VALID padding
- Tensorflow中padding的两种类型SAME和VALID