如图,摘自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))
嗯自己的理解是这样的