I can’t see any obvious error, which would create this high test loss and would recommend to debug a few iterations and check the output, target, as well as the loss calculation.
That being said, the code uses the deprecated Variables as well as the .data attribute, which might yield unwanted side effects, so you should remove it.
Also, these calls cuda().cpu() seem not to be necessary.