Skip to content

Commit db23d51

Browse files
Prevent use-before-init bug in LSML
As identified in gh-62.
1 parent cc88cbe commit db23d51

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

metric_learn/lsml.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,11 @@ def fit(self, X, constraints, weights=None):
6868
scale factor for each constraint
6969
"""
7070
self._prepare_inputs(X, constraints, weights)
71+
step_sizes = np.logspace(-10, 0, 10)
7172
prior_inv = scipy.linalg.inv(self.M_)
73+
# Keep track of the best step size and the loss at that step.
74+
l_best = 0
7275
s_best = self._total_loss(self.M_, prior_inv)
73-
step_sizes = np.logspace(-10, 0, 10)
7476
if self.verbose:
7577
print('initial loss', s_best)
7678
for it in xrange(1, self.max_iter+1):

0 commit comments

Comments
 (0)