9
$\begingroup$

ConvolutionalLayer has a few optional parameters. "Dilation" is one I'm having trouble understanding how it works and the documentation is terse.

Can anyone give some explanation?

References:

$\endgroup$
1

1 Answer 1

10
+100
$\begingroup$

The documentation will improve, hopefully with a picture.

In English terms, dilation 'stretches' the area over which the kernel is convolved, by subsampling the original data (sampling it every d+1 pixels).

In the meantime, here's something that lets you visualize the receptive field (the effective kernel) of a given kernelsize and dilation. Black pixels represent pixels that participate in the convolution, white pixels are ones that are skipped:

plotReceptiveField[kernel_, dilation_] := Module[
    {d = dilation+1},
    ArrayPlot[
        Drop[Array[
            If[Total[Mod[{##},d]] == 0, 1, 0]&, 
            kernel*d
        ], Sequence @@ dilation],
        Mesh -> True, ImageSize -> Small
    ]
]

Here are some pictures:

plotReceptiveField[{3, 3}, {0, 0}] (* no dilation *)

enter image description here

plotReceptiveField[{3, 3}, {1, 1}] (* uniform dilation of 1 *)

enter image description here

plotReceptiveField[{3, 3}, {2, 0}] (* non-uniform dilation *)

enter image description here

$\endgroup$
2
  • $\begingroup$ Thanks, and is the improved documentation expected in v11.0.1 or v11.1? $\endgroup$
    – M.R.
    Commented Sep 30, 2016 at 7:37
  • $\begingroup$ 11.0.1 ship sailed long ago. It'll have to be for 11.1 or 11.2 if we run out of time (I'm sure you'd rather prefer working recurrent networks than slightly improved documentation). $\endgroup$ Commented Oct 3, 2016 at 20:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.