I want to make dilated convolution on a feature. In tensorflow I found tf.nn.convolution
and tf.nn.conv2d
. But tf.nn.conv2d
doesn't seem to support dilated convolution.
So I tried using tf.nn.convolution
.
Do the 2 formulations below give the same result?
tf.nn.conv2d(x, w, strides=[1, 1, 2, 2], padding='SAME',data_format='NCHW')
tf.nn.convolution(x, w, strides=[1, 1, 2, 2], padding='SAME',data_format='NCHW')
To use dilated convolution, you need to use the following function:
tf.nn.atrous_conv2d(value, filters, rate, padding, name=None)
Reference: https://www.tensorflow.org/versions/r0.12/api_docs/python/nn/convolution#atrous_conv2d
Functionally, dilations
augument in tf.nn.conv2d
is the same as dilations_rate
in tf.nn.convolution
as well as rate
in tf.nn.atrous_conv2d
.
They all represent the rate by which we upsample the filter values by inserting zeros across the height and width dimensions. The dilation factor for each dimension of input specifying the filter upsampling/input downsampling rate otherwise known as atrous convolution.
The usage differs slightly. Let rate k >= 1
represent the dilation rate,
in tf.nn.conv2d
, the rate k
is passed as list of ints [1, k, k,1]
for [batch, rate_height, rate_width, channel]
.
in tf.nn.convolution
, rate k
is passed as a sequence of N
ints as [k,k]
for [rate_height, rate_width]
.
in tf.nn.atrous_conv2d
, rate k
is a positive int32
, a single value for both height and width. This library is deprecated and exists only for backwards compatibility.
Hope it helps :)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.