关于理解卷积操作中Padding的两种方式

参考博客

卷积操作存在两个问题:

1、图像越来越小;

2、图像边界信息丢失,即有些图像角落和边界的信息发挥作用较少。

因此需要padding

   

 一张M x M的图片,经过卷积核F x F,strides = [1,1,1,1], padding = valid 卷积操作后,

        得到大小为 C_side x C_side 的 feature map,

                其中,

                       C_side = M - ( F - 1 ),  即边长减少了 F-1个单位

 

若想保持卷积后的图像大小不变,需要在原图边长基础上padding F-1个单位的零元素,

即经过 strides = [1,1,1,1], padding = same 卷积操作后,

                       C_side = ( M +2P )- ( F - 1 ) = M

                       P = ( F - 1 )/ 2

一般的,卷积核边长大小F为奇数

1、方便padding = same卷积操作,左右(上下)两边对称补零;

2、奇数卷积核有中心像素,便于确定卷积核的位置。

 

当卷积步长strides不为1时,边长计算公式如下:

For the SAME padding, 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 VALID padding, 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]))

 

 

  • 7
    点赞
  • 30
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值