4
$\begingroup$

I'm implementing strided 2D convolution. My formula looks like this: $$y_{i, j} = \sum_{m=0}^{F_h - 1}\sum_{n=0}^{F_w - 1} x_{s\cdot i + m, s\cdot j + n}\,f_{m, n}, \tag{1}$$ where $s$ is the stride (some sources might refer to this as 'cross-correlation' but 'convolution' is consistent with PyTorch's definition)

I have calculated the gradient with respect to the filter as:

$$\frac{\partial E}{\partial f_{m', n'}} = \sum_{i=0}^{(x_h - F_h) / s}\sum_{j=0}^{(x_w - F_w) / s} x_{s\cdot i + m', s\cdot j + n'} \frac{\partial E}{\partial y_{i, j}} \tag{2}$$

and some simple dummy index relabeling leads to: $$\frac{\partial E}{\partial f_{i, j}} = \sum_{m=0}^{(x_h - F_h) / s}\sum_{n=0}^{(x_w - F_w) / s} x_{s\cdot m + i, s\cdot n + j} \frac{\partial E}{\partial y_{m, n}} \tag{3}$$

Equation $(3)$ looks similar to the first, but not exactly (the $s$ is on the wrong term!). My objective is to convert the second equation into 'convolutional form' so that I can calculate it using my existing, efficient convolution algorithm.

Could someone please help me work this out, or point out any errors that I have made?

$\endgroup$
3

0

You must log in to answer this question.

Browse other questions tagged .