conv2d函数中dilation参数:int or tuple

如图,摘自ERFNet中,在很多Net中都会出现dilation是tuple的情况:

nn.Conv2d(chann, chann, (1,3), stride=1, padding=(0,1*dilated), bias=True, dilation = (1, dilated))

在conv文件中指出,dilation可以是int或者tuple,所以dilation可能出现,dilation=2或dilation=(2,1)等情况:

 dilation (int or tuple, optional): Spacing between kernel elements. Default: 1

根据conv.py文件可以看出,dilation,扩张操作:控制kernel点(卷积核点)的间距

"""
attr:`dilation` controls the spacing between the kernel points; also known as the à trous algorithm.
    It is harder to describe, but this `link`_ has a nice visualization of what :attr:`dilation` does.

The parameters :attr:`kernel_size`, :attr:`stride`, :attr:`padding`, :attr:`dilation` can either be:
    - a single ``int`` -- in which case the same value is used for the height and width dimensions
    - a ``tuple`` of two ints -- in which case, the first `int` is used for the height dimension, 
    and the second `int` for the width dimension
"""

即对于kernel_size,stride,padding,dilation这四个参数而言,下面的描述都成立:

一个单一的int的情况下,相同的值被用于高度和宽度维度
一个两个int的`tuple'--在这种情况下,第一个`int'用于高度维度,第二个`int'用于宽度维度

 所以,这段代码表示,当dilation=2时,padding=(0,2),dilation=(1,2),图示为:

nn.Conv2d(chann, chann, (1,3), stride=1, padding=(0,1*dilated), bias=True, dilation = (1, dilated))

嗯自己的理解是这样的 

  • 3
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值