You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm confused by the practical formula for computing a discrete convolution after padding on p498. Shouldn't the index of x^{p} be [i+p-k] instead of [i+m-k]? So that x^{p}[i+p] and the original x[i] will have the same value.
The equation is correct. $x^p$ is the padded input vector, with $p$ zeros on each side of the vector. $k$ is the index of the summation. Let's assume n=8, m=3, and p=1, then x_p will have size 10, and the output elements are as follows:
y[0] => np.sum(x_p[:3:-1] * w[:])
y[1] => np.sum(x_p[1:4:-1] * w[:])
y[2] => np.sum(x_p[2:5:-1] * w[:])
...
so even if you change the padding, for example p=5; x_p will be padded with 5 zeros on left and ride, but the indexes in the above examples will stay the same:
y[0] => np.sum(x_p[:3:-1] * w[:])
y[1] => np.sum(x_p[1:4:-1] * w[:])
y[2] => np.sum(x_p[2:5:-1] * w[:])
...
The only difference is that x_p here has size n+2*p=18 (instead of 10).
Thank you for the quick response! Somehow in my mind I just ignored zeros padded on left of x_p and started from x_p[0+p] (the first element of non-zero x_p).
There's another thing I've noticed: if y[i], x_p[i], w[i] are all meant to be zero-indexed vectors, x_p[i+m-k] probably should be x_p[i+m-1-k], so that when y[i=0] and k=m-1, x_p[0] is the leftmost element to be used instead of x_p[1].
Activity
kmehrad commentedon Mar 3, 2020
So I think you are talking about this equation:

The equation is correct.
$x^p$ is the padded input vector, with $p$ zeros on each side of the vector. $k$ is the index of the summation. Let's assume n=8, m=3, and p=1, then x_p will have size 10, and the output elements are as follows:
y[0] => np.sum(x_p[:3:-1] * w[:])y[1] => np.sum(x_p[1:4:-1] * w[:])y[2] => np.sum(x_p[2:5:-1] * w[:])so even if you change the padding, for example p=5; x_p will be padded with 5 zeros on left and ride, but the indexes in the above examples will stay the same:
y[0] => np.sum(x_p[:3:-1] * w[:])y[1] => np.sum(x_p[1:4:-1] * w[:])y[2] => np.sum(x_p[2:5:-1] * w[:])The only difference is that x_p here has size
n+2*p=18(instead of 10).tlin40 commentedon Mar 3, 2020
Thank you for the quick response! Somehow in my mind I just ignored zeros padded on left of x_p and started from x_p[0+p] (the first element of non-zero x_p).
There's another thing I've noticed: if y[i], x_p[i], w[i] are all meant to be zero-indexed vectors, x_p[i+m-k] probably should be x_p[i+m-1-k], so that when y[i=0] and k=m-1, x_p[0] is the leftmost element to be used instead of x_p[1].
kmehrad commentedon Mar 4, 2020
Yes you are right, the current formula gives the following for
i=0:which is not correct, and instead should have been:
Thanks for bringing this to our attention. I did not realize this issue