Functional Conv2d Produces Different Results VS Scipy Convolved2d

PyTorch (and other ML frameworks that I know about) actually implement cross-correlation in the functions named convolution.

The difference is just the reversal of the filter.

filt = torch.from_numpy(np.ascontiguousarray(testFilt[::-1, ::-1])).type(torch.float32)
filt = filt.unsqueeze(0).unsqueeze(0)

Now it produces the same results.

4 Likes