Astrous Convolution

Astrous Convolution, or Dialated Convolution, is firstly introduced in paper Multi-Scale Context Aggregation by Dilated Convolutions. It is aimed to increase the size of reception field without increasing parameter sizes. It’s mainly use in the field of semantic segmentation. By stacking a series of dialated convolution with different rates(e.g., dialate [1, 3, 5] with 3x3 kernel), it can fully cover the original input features.

Standard Conv:

Dialated Conv:

Reception field size of n-dialated conv:

Standard discrete conv is just 1-dialated conv。

In tensorflow, we can either use tf.nn.conv2d or tf.nn.astrous_conv2d to perform a dialated conv operation. The following is a demonstration code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import tensorflow as tf
import numpy as np

matrix = np.array([
[1, 0, 1, 0, 1, 0, 1],
[1, 2, 3, 4, 5, 6, 7],
[1, 1, 1, 1, 1, 1, 1],
[2, 3, 2, 3, 2, 3, 2],
[1, 3, 1, 3, 1, 3, 1],
[1, 2, 3, 1, 2, 3, 1],
[1, 2, 3, 4, 1, 2, 3]
])
kernel = np.array([
[1, 1, 1],
[1, 2, 1],
[1, 1, 1]
])

matrix = np.expand_dims(np.expand_dims(matrix, axis = 3), axis = 0)
kernel = np.expand_dims(np.expand_dims(kernel, axis = 3), axis = 4)
tmatrix = tf.constant(matrix, dtype = tf.float32)
tkernel = tf.constant(kernel, dtype = tf.float32)
with tf.Session() as sess:
# The following 2 lines of code should have the same results.
_ret1 = sess.run(tf.nn.conv2d(tmatrix, tkernel, strides=[1, 1, 1, 1], padding = "VALID", dilations=[1, 2, 2, 1]))
_ret2 = sess.run(tf.nn.atrous_conv2d(tmatrix, tkernel, padding = "VALID", rate = 2))

References

[1] https://www.zhihu.com/question/54149221
[2] Rethinking Atrous Convolution for Semantic Image Segmentation
[3] Understanding 2D Dilated Convolution Operation with Examples in Numpy and Tensorflow with Interactive Code

AutoEncoders MobileNets: Efficient Convolutional Neural Networks for Mobile Vision Applications

Комментарии

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×