2D Convolution and dilation

Tomojit: <p>Hi - The 2d convolution of PyTorch has the default value of dilation set to 1. This means I have to use dilation. Why this is set up in this way? If I want to convolve an image with a [3 x 3] kernel, the default setting of dilation is making the kernel effectively a [5 x 5] one. Is there any way to use a kernel without dilation?</p>

Nikronic: <p>Hi,<br>
It’s not true.</p>
<aside class="quote no-group" data-username="Tomojit" data-post="1" data-topic="100227">
<div class="title">
<div class="quote-controls"></div>
<img loading="lazy" alt="" width="24" height="24" src="https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/tomojit/48/29601_2.png" class="avatar"> Tomojit:</div>
<blockquote>
<p>the default setting of dilation is making the kernel effectively a [5 x 5] one</p>
</blockquote>
</aside>
<p>You may want to check the formulation <a href="https://pytorch.org/docs/stable/generated/torch.nn.Conv2d.html" rel="noopener nofollow ugc">Conv2d — PyTorch 1.6.0 documentation</a>:</p>
<p><div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/5/b/5bd0f6e246e887488f6211694ca2f13a67424b79.png" data-download-href="https://discuss.pytorch.org/uploads/default/5bd0f6e246e887488f6211694ca2f13a67424b79" title="image"><img src="https://discuss.pytorch.org/uploads/default/original/3X/5/b/5bd0f6e246e887488f6211694ca2f13a67424b79.png" alt="image" data-base62-sha1="d6f9xN62iadWvcr8Wp2WCRR4xbX" width="690" height="185" data-dominant-color="212323"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">image</span><span class="informations">722×194 13.6 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p>
<p>Also, this is the convention, as far as I know, TF, keras, etc all use conv layers the same way PyTorch uses as it should match mathematical formulation of conv.</p>
<p>Bests</p>

Tomojit: <p>Hi <a class="mention" href="/u/nikronic">@Nikronic</a> - Thanks for your reply. I’m aware of the convolutional convention. As per the PyTorch documentation dilation add spaces between the kernel elements. So it’s effectively inflating the kernel size.<br>
Getting back to my main point, is there any way to convolve an image without dilation in PyTorch? Some of early papers (specifically 2012-2016) on ConvNet, authors just used pain convolution. I want to recreate some of the papers. That’s why I need to convolve an image with out dilation. Any help will be appreciated.</p>
<p>Thanks,<br>
Tomojit</p>

Nikronic: <p>Apparently, I expressed the idea badly.<br>
Default value, <code>dilation=1</code> means no dilation.<br>
I think this thread explains situation clearly:</p>
<p><a href="https://discuss.pytorch.org/t/why-the-default-dilation-value-in-conv2d-is-1/5612">Why the default dilation value in Conv2d is 1? - PyTorch Forums</a></p>

Tomojit: <p>Ok, it’s looks like dilation=1 means “no dilation”, which is a bit confusing. Anyway, if I use the default setting for dilation, then I’m not convolving an image with a dilated kernel.</p>

AKasper: <p>For anyone having issues with this you can see dilation as the number of steps taken between the kernel weights. So if dilation were to be 0 it would stay at one spot.</p>