Thanks for the reply, TinfoilHat0!
Is there a way to get the gradient for each element of the batch that way? As I understand it, weight.grad contains the values after applying the aggregate function to the batch.
Also, I didn’t explain it well enough, but the aggregate function to be modified is more complex, and cannot be achieved by simply multiplying the loss.