Skip to content

Commit 4d61dba

Browse files
author
William de Vazelhes
committed
Better creation of prior
1 parent eb95719 commit 4d61dba

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

metric_learn/sdml.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,15 @@ def _fit(self, pairs, y):
6868
pairs, y = self._prepare_inputs(pairs, y,
6969
type_of_inputs='tuples')
7070

71-
# set up prior M
71+
# set up (the inverse of) the prior M
7272
if self.use_cov:
7373
X = np.vstack({tuple(row) for row in pairs.reshape(-1, pairs.shape[2])})
74-
prior = pinvh(np.atleast_2d(np.cov(X, rowvar=False)))
74+
prior_inv = np.atleast_2d(np.cov(X, rowvar=False))
7575
else:
76-
prior = np.identity(pairs.shape[2])
76+
prior_inv = np.identity(pairs.shape[2])
7777
diff = pairs[:, 0] - pairs[:, 1]
7878
loss_matrix = (diff.T * y).dot(diff)
79-
emp_cov = pinvh(prior) + self.balance_param * loss_matrix
79+
emp_cov = prior_inv + self.balance_param * loss_matrix
8080

8181
# our initialization will be the matrix with emp_cov's eigenvalues,
8282
# with a constant added so that they are all positive (plus an epsilon

0 commit comments

Comments
 (0)