文章目录
常见的卷积有:因果、depthwise、pointwise、空洞、转置卷积等,如何区分它们呢?
首先卷积可以分为一维卷积和二维卷积
- Conv1D
- Conv2D
还可包括
- Conv1DTranspose, Conv2DTranspose
- SeparableConv1D, SeparableConv2D
Conv1D
因果卷积
padding=causal
注:Conv2D的padding只有same和valid,没有causal,所以只有一维因果卷积。
空洞卷积
dilation_rate>1
因果空洞卷积
padding=causal
dilation_rate>1
SeparableConv1D
继承自SeparableConv:
Depthwise separable 1D convolution:This layer performs a depthwise convolution
that acts separately on channels, followed by a pointwise convolution
that mixes channels.
Conv2D
- 输入参数:指需要做卷积的输入图像/音频等,它要求是一个Tensor,具有
[batch, in_height, in_width, in_channels]
这样的shape,具体图片的含义是[训练时一个batch的图片数量, 图片高度, 图片宽度, 图像通道数],注意这是一个4维的Tensor,要求类型为float32和float64其中之一。
主要参数包括:
filters
:卷积核个数,也是输出通道数。Integer, the dimensionality of the output space (i.e. the number of output filters in the convolution).kernel_size
: 卷积核大小,指定二维卷积窗口的高和宽,(如果kernel_size只有一个整数,代表宽和高相等):An integer or tuple/list of 2 integers, specifying the height and width of the 2D convolution window. Can be a single integer to specify the same value for all spatial dimensions.strides
: 卷积步长,指定卷积窗沿高和宽方向的每次移动步长,An integer or tuple/list of 2 integers, (如果strides只有一个整数,代表沿着宽和高方向的步长相等) specifying the strides of the convolution along the height and width. Can be a single integer to specify the same value for all spatial dimensions. Specifying any stride value != 1 is incompatible with specifying anydilation_rate
value != 1.padding
: 为valid或same中一种, one of"valid"
or"same"
(case-insensitive).
单通道与多通道 卷积
in_channels:
- in_channels=1:单通道卷积
- in_channels>1:多通道卷积
单卷积核与多卷积核 卷积
卷积核个数filters:
- filters>1:多卷积核卷积
- filters=1:单卷积核卷积
DepthwiseConv2D
DepthwiseConv2D继承Conv2D,但是没有filters参数,即默认filters=in_channels>1(多通道卷积)
Pointwise Convolution
kernel_size=[1, 1]
filters>1
SeparableConv2D
继承自SeparableConv
Depthwise Separable Convolution,即 Depthwise Convolution + Pointwise Convolution
空洞卷积
也叫膨胀卷积、扩张卷积,即dilated Conv:
dialation_rate > 1
一维二维卷积均可进行空洞卷积。
Conv2DTranspose
继承自Conv2D。
Transposed convolution layer (sometimes called Deconvolution)
转置卷积,也叫反卷积。