Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I implement dilated convolution in keras?

I want to use dilated convolution in Keras. I found AtrousConv2D but could not find any definition for it in the Keras docs and when I use

acov=AtrousConv2D((3,3))(image)

it produces this error

init() missing 1 required positional argument: 'kernel_size'

I need dilation convolution but I do not know how can I use this layer or how can I produce this layer myself.

like image 610
david Avatar asked Feb 21 '19 01:02

david


People also ask

What is dilation convolution?

Dilated Convolution: It is a technique that expands the kernel (input) by inserting holes between its consecutive elements. In simpler terms, it is the same as convolution but it involves pixel skipping, so as to cover a larger area of the input.

What is dilation rate in keras?

Dilated convolutions introduce another parameter to convolutional layers called the dilation rate. This defines a spacing between the values in a kernel. A 3x3 kernel with a dilation rate of 2 will have the same field of view as a 5x5 kernel, while only using 9 parameters.

What is dilated causal convolution?

A Dilated Causal Convolution is a causal convolution where the filter is applied over an area larger than its length by skipping input values with a certain step. A dilated causal convolution effectively allows the network to have very large receptive fields with just a few layers.

Does dilated convolution reduces the dimension of the data?

it preserves the resolution/dimensions of data at the output layer. This is because the layers are dilated instead of pooling, hence the name dilated causal convolutions. it maintains the ordering of data.


1 Answers

The standard keras Conv2D layer supports dilation, you just need to set the dilation_rate to a value bigger than one. For example:

out = Conv2D(10, (3, 3), dilation_rate=2)(input_tensor)
like image 189
Dr. Snoopy Avatar answered Sep 21 '22 07:09

Dr. Snoopy