Rakshit_Kothari:

Running the same piece of code with N = 5000 returns weird numbers in the loss for elements to be ignored. Values such as .0646e+24 etc.


This might be a bug, as it seems the values are uninitialized.
I cannot reproduce it using your (modified) code for N = 5000.
Also note, that your criterion should get the prediction as the first argument and the target as the second.
reduction should be set as 'none' (lowercase n).