How to modify loss value after forward pass (but before backprop.)?

Is it possible to alter the magnitude of loss after forward pass? I tried using to assign a new value. But the gradients are still being computed on the old value.


The gradients do not depend on the actual value of the loss in most cases. So that’s why you don’t see any change when you change it.
Note that I would advise again using .data as it will most likely lead to wrong gradients being computed!