From cd935ac86014a65722c1859919dd27bd0755db03 Mon Sep 17 00:00:00 2001 From: KarhouTam Date: Sat, 16 Mar 2024 10:54:36 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9E=20fix(scheme):=20Fixed=20scheme=20?= =?UTF-8?q?`randomly=5Fassign=5Fclasses`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Seems `random.sample()` in python 3.12 changed that need the `populaton` arg to be a sequence --- data/utils/schemes/randomly_assign_classes.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/data/utils/schemes/randomly_assign_classes.py b/data/utils/schemes/randomly_assign_classes.py index a97d92a..637f591 100644 --- a/data/utils/schemes/randomly_assign_classes.py +++ b/data/utils/schemes/randomly_assign_classes.py @@ -27,8 +27,9 @@ def randomly_assign_classes( data_idx_for_each_label = {i: np.where(targets == i)[0].tolist() for i in label_set} assigned_labels = [] selected_times = {i: 0 for i in label_set} + label_sequence = sorted(label_set) for i in range(client_num): - sampled_labels = random.sample(label_set, class_num) + sampled_labels = random.sample(label_sequence, class_num) assigned_labels.append(sampled_labels) for j in sampled_labels: selected_times[j] += 1