Atrous Convolution and Depthwise Convolution

03 December 2018

待补充..

本篇介绍这两种卷积

  • 空洞卷积
  • Depthwise 卷积

空洞卷积

空洞卷积是deeplab网络里基本的操作。

Tensorflow中的空洞卷积操作

import numpy as np
import tensorflow as tf

value = tf.constant([[[[3], [3], [3], [3], [3]],
                     [[3], [2], [2], [2], [3]],
                     [[3], [2], [1], [2], [3]],
                     [[3], [2], [2], [2], [3]],
                     [[3], [3], [3], [3], [3]]]], dtype=tf.float32)

filter = tf.constant(1, shape=[3, 3, 1, 1], dtype=tf.float32)

res_rate_1_valid = tf.nn.atrous_conv2d(value=value, filters=filter, rate = 1, padding='VALID')
res_rate_2_valid = tf.nn.atrous_conv2d(value=value, filters=filter, rate = 2, padding='VALID')
res_rate_1_same = tf.nn.atrous_conv2d(value=value, filters=filter, rate = 1, padding='SAME')
res_rate_2_same = tf.nn.atrous_conv2d(value=value, filters=filter, rate = 2, padding='SAME')

sess = tf.Session()

res_rate_1_val_valid = sess.run(res_rate_1_valid)
res_rate_2_val_valid = sess.run(res_rate_2_valid)
res_rate_1_val_same = sess.run(res_rate_1_same)
res_rate_2_val_same = sess.run(res_rate_2_same)

print res_rate_1_val_valid, res_rate_1_val_valid.shape
print res_rate_2_val_valid, res_rate_2_val_valid.shape
print res_rate_1_val_same, res_rate_1_val_same.shape
print res_rate_2_val_same, res_rate_2_val_same.shape

depthwise卷积

这个还没有细看过,之后再整理。