Project DelphiTensors Workshop

Mistake: convolution and correlation are the same thing

“Sliding a kernel and multiplying is convolution, whichever way you write it.”

x = np.array([1., 2., 3., 4., 5.]) k = np.array([1., 2., 3.]) corr = np.array([(x[i:i + 3] * k).sum() for i in range(3)]) conv = np.convolve(x, k, mode="valid") assert not np.allclose(corr, conv) assert np.allclose(corr, np.convolve(x, k[::-1], mode="valid"))

Convolution flips the kernel before sliding it, so the two disagree on an asymmetric one. Flip it yourself and correlation reproduces convolution exactly.

For a symmetric kernel the distinction vanishes, which is why it goes unnoticed — and why deep-learning “convolution” layers are correlation.