Skip to content

Commit

Permalink
fix unnecessary indentation (repeated torch.tensor conversions)
Browse files Browse the repository at this point in the history
  • Loading branch information
AngledLuffa committed Dec 31, 2023
1 parent 1aa8dd0 commit 1d4083b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion stanza/models/lemma_classifier/train_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def configure_weighted_loss(self, label_decoder: Mapping, counts: Mapping):
total_samples = sum(counts.values())
for class_idx in counts:
weights[class_idx] = total_samples / (counts[class_idx] * len(counts)) # weight_i = total / (# examples in class i * num classes)
weights = torch.tensor(weights)
weights = torch.tensor(weights)
logging.info(f"Using weights {weights} for weighted loss.")
self.criterion = nn.BCEWithLogitsLoss(weight=weights)

Expand Down

0 comments on commit 1d4083b

Please sign in to comment.