Open BabaUtah opened 2 years ago
Hi! While executing the following code given for the poisoning attack :
from cvxpylayers.tensorflow.cvxpylayer import CvxpyLayer from sklearn.datasets import make_blobs from sklearn.model_selection import train_test_split tf.random.set_seed(0) np.random.seed(0) n = 2 N = 60 X, y = make_blobs(N, n, centers=np.array([[2, 2], [-2, -2]]), cluster_std=3) Xtrain, Xtest, ytrain, ytest = train_test_split(X, y, test_size=.5) Xtrain, Xtest, ytrain, ytest = map( tf.constant, [Xtrain, Xtest, ytrain, ytest]) m = Xtrain.shape[0] lambda1_tf = tf.constant([[0.1]], dtype=tf.float64) lambda2_tf = tf.constant([[0.1]], dtype=tf.float64) a = cp.Variable((n, 1)) b = cp.Variable((1, 1)) lambda1 = cp.Parameter((1, 1), nonneg=True) lambda2 = cp.Parameter((1, 1), nonneg=True) X = cp.Parameter((m, n)) Y = ytrain.numpy()[:, np.newaxis] log_likelihood = (1. / m) * cp.sum( cp.multiply(Y, X @ a + b) - cp.log_sum_exp(cp.hstack([np.zeros((m, 1)), X @ a + b]).T, axis=0, keepdims=True).T ) regularization = - lambda1 * cp.norm(a, 1) - lambda2 * cp.sum_squares(a) prob = cp.Problem(cp.Maximize(log_likelihood + regularization)) fit_logreg = CvxpyLayer(prob, [X, lambda1, lambda2], [a, b])
I encounter the following error :
--------------------------------------------------------------------------- TypeError Traceback (most recent call last) <ipython-input-39-46df02174119> in <module>() 38 regularization = - lambda1 * cp.norm(a, 1) - lambda2 * cp.sum_squares(a) 39 prob = cp.Problem(cp.Maximize(log_likelihood + regularization)) ---> 40 fit_logreg = CvxpyLayer(prob, [X, lambda1, lambda2], [a, b]) /usr/local/lib/python3.7/dist-packages/cvxpylayers/tensorflow/cvxpylayer.py in __init__(self, problem, parameters, variables, gp) 73 raise ValueError('Problem must be DPP.') 74 else: ---> 75 if not problem.is_dcp(dpp=True): 76 raise ValueError('Problem must be DPP.') 77 if set(parameters) != set(problem.parameters()): TypeError: _compute_once() got an unexpected keyword argument 'dpp'
Any idea to overcome this issue ?
Try upgrading your version of CVXPY
Hi! While executing the following code given for the poisoning attack :
I encounter the following error :
Any idea to overcome this issue ?