CNN convolution Summary

 

1, the convolution function: decrease the parameter (parameter sharing convolution kernel), a convolution process to continuously output the abstract, is summarized by the local feature global feature (convolutional different layers may be observed that the visual point)

2, convolution kernel

Early convolution kernel summarized manually, as there are image processing:

The depth of the neural network, the convolution kernel network training process by learning to get.

3, the neural network convolution type

  • Group convolution: packet convolution. After each convolution passage channel grouping. Reduction parameters.

Such as input and output channels is 64, the size of the convolution kernel is a 3 * 3, the original parameters in an amount of 64 * 64 * 3 * 3 = 36864, channels are grouped into 8 groups 32 are input and output, an amount of parameter 8 * 8 * 8 * 3 * 3 = 4608. Original 1/8.

  • Convolution Depthwise : convolution depth of 1, only the convolution of the space portion of the corresponding channel
  • Pointwise convolution: the convolution kernel size is 1 * 1, only the convolution of channel portions
  • Depthwise Separable convolution: 2 above were combined for this purpose, ie. The first portion of the convolution of each spatial channel, then the convolution of each channel, the spatial separation of the channel. Reduction parameters.

For example, input channels 16, output channels 32, using 3 * 3 convolution kernel size, if the direct convolution, the convolution kernel we need 32, each parameter is 16 * 3 * 3, a total of 32 parameters * 3 * 3 * 16 = 4608. When operated separately, the first step, we each convolution kernel convolution only one input channel, i.e. space portion convolution , the convolution kernel requires 16 each 1 * 3 * 3, a total of 144 parameters; first two steps, on the part of the channel convolution , convolution space not required at this time, so the convolution kernel size is 1 * 1 (i.e., to preserve the original spatial information), the convolution of the channel 16, i.e. a convolution kernel parameter 1 * 1 * 16, the output 32 with a convolution kernel 32, 16 * 32 = 512 parameter. The total parameter 656. Parameters for the amount of the original 1/7. More spatial channels and independent data, this method is not only efficient but good effect.

  • Dilated convolution:空洞卷积。解决下采样(pooling)过程中信息丢失问题,实现像素级的语义分割。

 

 如图,卷积核大小不变,但是中间可以留空,这样可以增大卷积核的视野,而无需扩大卷积核大小(增加参数/计算量)。

  • 反卷积(转置卷积):反卷积核与元素卷积核的输入输出shape是交换形式,实现还原原始shape的操作。

4,tensorflow实现

常规卷积

tf.nn.conv2d(input, filter, strides, padding, use_cudnn_on_gpu=None, data_format=None, Name=None)

可以用高级API,这里步长对于样本和通道维度默认设为1了,所以只有2个参数。对于dilation也是如此。同时还有trainable等特性。

tf.layers.Conv2D(
    filters, kernel_size, strides=(1, 1), padding='valid', data_format='channels_last', dilation_rate=(1, 1), activation=None, use_bias=True, kernel_initializer=None, bias_initializer=<tensorflow.python.ops.init_ops.Zeros object at 0x000001ECFFC4D188>, kernel_regularizer=None, bias_regularizer=None, activity_regularizer=None, kernel_constraint=None, bias_constraint=None, trainable=True, name=None, **kwargs, )

Depthwise convolution

tf.nn.depthwise_conv2d(input, filter, strides, padding, rate=None, name=None, data_format=None)

Separable convolution

tf.nn.separable_conv2d(input, depthwise_filter, pointwise_filter, strides, padding, rate=None, name=None, data_format=None)

反卷积

tf.nn.conv2d_transpose(value, filter, output_shape, strides, padding="SAME", data_format="NHWC", name=None)

以上参数就不具体说明了,在此只是作个汇总,方便查看。

 参考资料

https://www.cnblogs.com/noticeable/p/9197640.html

https://www.cnblogs.com/cvtoEyes/p/8848815.html

 

Guess you like

Origin www.cnblogs.com/lunge-blog/p/11876606.html