You have mixed up the input and weight in the call to F.conv2d. Input goes first.
If you’re comparing to pen and paper, note that the PyTorch convolutions (and just about everyone else’s) are correlations, i.e. no flipping of the axes before summation occurs.
Best regards
Thomas
P.S.: This would have been easy to spot had you used different sizes for weights and inputs. (Edit: I should say I’m a bit prone to this type of error myself and that is why I try to make a habit of trying to make tensor dimensions as unique as possible. We all started confused at some point.)