Hi,
due to the nature of the loss that I implemented, it is only possible to compute it through a for-loop. When doing so, I run out of cuda memory. Here is the code:

    for i in range(n_predictions):
        for j in range(i,n_predictions):
            loss += multiplicator[j]/\
                    (1+torch.exp(-self.gamma*(prediction[i]-prediction[j])))


I assume that due to “loss += …” a new graph is constructed each time? How can I prevent this?
Thanks in advance!