Skip to content

Commit

Permalink
🐞 fix(scheme): Fixed scheme randomly_assign_classes
Browse files Browse the repository at this point in the history
Seems `random.sample()` in python 3.12 changed that need the `populaton` arg to be a sequence
  • Loading branch information
KarhouTam committed Mar 16, 2024
1 parent 234f25d commit cd935ac
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion data/utils/schemes/randomly_assign_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit cd935ac

Please sign in to comment.