Skip to content

Instantly share code, notes, and snippets.

@jgoodie
Created May 27, 2024 03:32
Show Gist options
  • Save jgoodie/37848bde13486ed851c5fdcae3139e4d to your computer and use it in GitHub Desktop.
Save jgoodie/37848bde13486ed851c5fdcae3139e4d to your computer and use it in GitHub Desktop.
sample_weights = compute_sample_weight(class_weight='balanced',y=df.label)
label_weights = { k:v for k, v in sorted(list(zip(df.label, sample_weights)))}
label_weights = torch.tensor(list(label_weights.values()), dtype=torch.float32)
label_weights
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment