You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I applied cvxpylayer in my project, I found a problem in cvxpylayer. This leads to KeyError, when we deepcopy a existing module that contains cvxpylayer. For example, you can try the code below.
import cvxpy as cp
from cvxpylayers.torch import CvxpyLayer
import torch
import copy
n = 6
m = 3
x = cp.Variable(n)
x_prime = cp.Parameter(n)
constraints = [cp.pnorm(x, 2) <= m]
objective = cp.Minimize(0.5 * cp.pnorm(x - x_prime, 2))
problem = cp.Problem(objective, constraints)
assert problem.is_dpp()
projection = CvxpyLayer(problem, parameters=[x_prime], variables=[x])
s=torch.nn.Sequential(projection)
s=s.cuda()
sc=copy.deepcopy(s)
x=torch.randn(100,n, requires_grad=True)
sc(x)
The text was updated successfully, but these errors were encountered:
When I applied cvxpylayer in my project, I found a problem in cvxpylayer. This leads to KeyError, when we deepcopy a existing module that contains cvxpylayer. For example, you can try the code below.
The text was updated successfully, but these errors were encountered: