来个详细版的如下:
来个简版的如下:
padding =“SAME”的情况:
这里插一句帮助理解:自动补全的话,考虑步长为1,每一卷积从第一个维度开始一步一步移动,直到最后一个维度,那么输出肯定是和原来的维度一样,如果步长不是1比如为2 就要向上取整。比如7*7的图像采用3*3大小的卷积核进行卷积操作,padding = “SAME”的情况下就是[7/3] = 4,最后输出为4*4大小的feature map
没图说个基:
① padding = “value”, stride = 4, (227 - 11 + 2*0)/ 4 + 1 = 55
② padding = “value”, stride = 2, (55 - 3 + 2*0)/ 2 + 1 = 27
③ padding = “same”, stride = 1, 27 / 1 = 27
④ padding = “value”,stride = 2, (27 - 3 + 2*0) / 2 + 1 = 13
来个例子:
input = tf.Variable(tf.random_normal([64,5,5,3])) filter = tf.Variable(tf.random_normal([3,3,3,16])) op_1 = tf.nn.conv2d(input,filter,strides = [1,1,1,1],padding = "SAME") op_2 = tf.nn.conv2d(input,filter,strides = [1,2,2,1],padding = "SAME") init = tf.global_variables_initializer() sess = tf.InteractiveSession() sess.run(init) print(np.shape(sess.run(op_1))) print(np.shape(sess.run(op_2)))
output:
(64, 5, 5, 16)
(64, 3, 3, 16) </div>