meg HF Staff commited on
Commit
03e9604
·
verified ·
1 Parent(s): 31f2126

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -2
app.py CHANGED
@@ -46,7 +46,7 @@ def get_label_fractions(dataset):
46
  return label_list, label_fractions
47
 
48
 
49
- def randomize_labels(examples, indices):
50
  # What set of examples should be randomized in this batch?
51
  # This is the intersection of the batch indices and the indices we randomly selected to change the labels of.
52
  batch_subset = list(set(indices) & randomize_subset)
@@ -90,7 +90,8 @@ def main(percentage=10):
90
  new_random_labels = list(choice(a=label_list, size=num_new_labels, p=label_fractions))
91
 
92
  # Update the dataset so that the labels are randomized
93
- updated_dataset = dataset.map(randomize_labels, with_indices=True,
 
94
  features=dataset.features, batched=True)
95
 
96
  # Upload the new version of the dataset (this will take awhile)
 
46
  return label_list, label_fractions
47
 
48
 
49
+ def randomize_labels(examples, indices, new_random_labels):
50
  # What set of examples should be randomized in this batch?
51
  # This is the intersection of the batch indices and the indices we randomly selected to change the labels of.
52
  batch_subset = list(set(indices) & randomize_subset)
 
90
  new_random_labels = list(choice(a=label_list, size=num_new_labels, p=label_fractions))
91
 
92
  # Update the dataset so that the labels are randomized
93
+ updated_dataset = dataset.map(randomize_labels, with_indices=True,
94
+ fn_kwargs={'new_random_labels':new_random_labels},
95
  features=dataset.features, batched=True)
96
 
97
  # Upload the new version of the dataset (this will take awhile)