Skip to content

Commit 02cc937

Browse files
author
William de Vazelhes
committed
FIX: make proposal for sdml formulation
1 parent 8ffd998 commit 02cc937

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

metric_learn/sdml.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,12 @@ def _fit(self, pairs, y):
5858
# set up prior M
5959
if self.use_cov:
6060
X = np.vstack({tuple(row) for row in pairs.reshape(-1, pairs.shape[2])})
61-
self.M_ = pinvh(np.cov(X, rowvar = False))
61+
self.M_ = np.cov(X, rowvar = False)
6262
else:
6363
self.M_ = np.identity(pairs.shape[2])
6464
diff = pairs[:, 0] - pairs[:, 1]
6565
loss_matrix = (diff.T * y).dot(diff)
66-
P = self.M_ + self.balance_param * loss_matrix
67-
emp_cov = pinvh(P)
68-
# hack: ensure positive semidefinite
69-
emp_cov = emp_cov.T.dot(emp_cov)
66+
emp_cov = self.M_ + self.balance_param * loss_matrix
7067
_, self.M_ = graph_lasso(emp_cov, self.sparsity_param, verbose=self.verbose)
7168

7269
self.transformer_ = transformer_from_metric(self.M_)

0 commit comments

Comments
 (0)