From 24f64805178355dbe8b3ca11a647469a18793757 Mon Sep 17 00:00:00 2001 From: Jacques Arnoux Date: Sun, 4 Dec 2022 17:27:10 -0800 Subject: [PATCH] Fixes random seeding `self.already_selected` is initialized to `[]` in the constructor but is never assigned `None` so that will always be false. If `already_selected` is empty, `ind` will be initialized to `np.argmax(self.min_distances)`, which was initialized to `None` and never reassigned so the first selected datapoint will always be `np.argmax(None) = 0` --- sampling_methods/kcenter_greedy.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sampling_methods/kcenter_greedy.py b/sampling_methods/kcenter_greedy.py index ff7e548..d9b8a05 100644 --- a/sampling_methods/kcenter_greedy.py +++ b/sampling_methods/kcenter_greedy.py @@ -102,7 +102,7 @@ def select_batch_(self, model, already_selected, N, **kwargs): new_batch = [] for _ in range(N): - if self.already_selected is None: + if self.min_distances is None: # Initialize centers with a randomly selected datapoint ind = np.random.choice(np.arange(self.n_obs)) else: