这里单独把计算卷积之后的维度的公式拿出来,方便查看
1.卷积后尺寸计算
out_height=(in_height+2pad-filter_height)/strides[1]+1
out_width=(in_width+2pad-filter_width)/strides[2] +1
2.tensorflow中卷积参数same和valid运算之后的维度计算
(1)same
out_height=ceil(float(in_height))/float(strides[1])
out_width=ceil(float(in_width))/float(strides[2])
(2)valid
out_height=ceil(float(in_height-filter_height+1))/float(strides[1])
out_width=ceil(float(in_width-filter_width+1))/float(strides[2])
(3)参数
padding: SAME和VALID两种形式
filter: [5,5,1,32]表示5*5的卷积核,1个channel,32个卷积核。
strides: [1,4,4,1]表示横向和竖向的步长都为4
3.tensorflow里面的tf.pad函数
虽然在卷积过程中有same选项可选,但是tensorflow里面还有一个可以用于填充的函数tf.pad(),具体用法如下:
tf.pad(tensor, paddings,mode='CONSTANT',name=