Skip to content

Commit f4545e2

Browse files
Final c
1 parent 763e151 commit f4545e2

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

ML/helper_functions/test.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,17 @@ def test(self):
2121
p_tot = 0
2222
r_tot = 0
2323
f1_tot = 0
24+
l_tot = 0
2425
n = 0
2526
with torch.inference_mode():
2627
for X, y in self.test_dataloader:
2728
y = y[0]
2829
X = F.to_tensor(X, padding_value=1).to("cuda")
2930
y = torch.tensor(y).to("cuda")
3031
preds = torch.argmax(torch.softmax(self.model(X), dim=1), dim=1)
32+
loss = self.criteria(preds, y.view(-1, 1).squeeze(1))
3133
results = classification_report(
32-
preds, y.view(-1, 1).squeeze(1), class_names=["0", "1"]
34+
preds.cpu(), y.view(-1, 1).squeeze(1).cpu(), output_dict=True
3335
)
3436
precision = results["weighted avg"]["precision"]
3537
recall = results["weighted avg"]["recall"]
@@ -39,10 +41,12 @@ def test(self):
3941
p_tot += precision
4042
r_tot += recall
4143
f1_tot += f1score
44+
l_tot += loss.item()
4245
n += 1
4346
return {
4447
f"{self.name} precision": p_tot / n,
4548
f"{self.name} recall": r_tot / n,
4649
f"{self.name} f1-score": f1_tot / n,
4750
f"{self.name} accuracy": a_tot / n,
51+
f"{self.name} loss": l_tot / n,
4852
}

ML/modelling/tt.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ def __init__(
77
num_classes: int = 2,
88
input_dim: int = 768,
99
classifier_head: torchtext.models = RobertaClassificationHead,
10-
model: torchtext.models = XLMR_BASE_ENCODER,
10+
model: torchtext.models = XLMR_LARGE_ENCODER,
1111
) -> None:
1212
super().__init__()
1313
self.num_classes = num_classes

wandb/latest-run

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
run-20230726_185833-04448s1w
1+
run-20230726_190040-w6tkx4xt

0 commit comments

Comments
 (0)