Skip to content

Commit

Permalink
Added scaling for norm
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffrey-hokanson committed Mar 16, 2019
1 parent 7578300 commit 6a70170
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions psdr/lipschitz.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,13 +230,13 @@ def _build_lipschitz_matrix_cvxopt(self, X, fX, grads):
for i in range(len(X)):
for j in range(i+1,len(X)):
p = X[i] - X[j]

p_norm = np.linalg.norm(p)
# Vectorize to improve performance
#G = [-p.dot(E.dot(p)) for E in Es]
G = -np.tensordot(np.tensordot(Eten, p, axes = (2,0)), p, axes = (1,0))
G = -np.tensordot(np.tensordot(Eten, p/p_norm, axes = (2,0)), p/p_norm, axes = (1,0))

Gs.append(cvxopt.matrix(G).T)
hs.append(cvxopt.matrix( [[ -(fX[i] - fX[j])**2]]))
hs.append(cvxopt.matrix( [[ -(fX[i] - fX[j])**2/p_norm**2]]))

# Add constraint to enforce H is positive-semidefinite
# Flatten in Fortran---column major order
Expand Down

0 comments on commit 6a70170

Please sign in to comment.