How did you initialize the criterion?
Note that 'mean' should be passed as a string.
Also, in older PyTorch versions (pre 1.0), you had to use 'elementwise_mean' as far as I remember.
If you are using one of the older versions, I would strongly recommend to update.