I think this is the reason.



2 FOR loops, having RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation


I think I figured out why. The problem is the following line:



2 FOR loops, having RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation


> # update the slack variable
            self.value.lam = self.value.lam + self.value.c * e_v
> ```



At the outer loop, I update the lambda. However, because e_v is returned as a tensor, so does the lambda instead of being a float value.
That means my network is going to change if I change the lambda again.
Correct me if I am wrong.
Thanks,