Skip to content

Commit 612fcc4

Browse files
Hack around missing impostors issue
1 parent 66a12ed commit 612fcc4

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

metric_learn/lmnn.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,10 @@ def fit(self, X, y):
180180
G, objective, total_active = self._loss_grad(X, L, dfG, k,
181181
reg, target_neighbors,
182182
label_inds)
183+
if G is None:
184+
# TODO: raise a warning
185+
self.n_iter_ = 0
186+
return self
183187

184188
it = 1 # we already made one iteration
185189

@@ -244,6 +248,8 @@ def _loss_grad(self, X, L, dfG, k, reg, target_neighbors, label_inds):
244248
Ni.argmax(axis=1)[:, None], 1)
245249
impostors = self._find_impostors(furthest_neighbors.ravel(), X,
246250
label_inds, L)
251+
if not impostors:
252+
return None, 0, 0
247253

248254
g0 = _inplace_paired_L2(*Lx[impostors])
249255

0 commit comments

Comments
 (0)