init
Browse files
experiments/model_predict_ner.py
CHANGED
@@ -94,8 +94,8 @@ class NER:
|
|
94 |
output = self.model(**{
|
95 |
k: torch.tensor(encoded_input[k]).to(self.device) for k in input_keys if k in encoded_input
|
96 |
})
|
97 |
-
prob = torch.softmax(output['logits'], dim=-1)
|
98 |
-
print(prob)
|
99 |
pred = torch.max(prob, dim=-1)[1].cpu().detach().int().tolist()
|
100 |
preds += [[self.id_to_label[_p] for _p in p] for p in pred]
|
101 |
return [{"prediction": p, "label": i} for p, i in zip(preds, labels)]
|
|
|
94 |
output = self.model(**{
|
95 |
k: torch.tensor(encoded_input[k]).to(self.device) for k in input_keys if k in encoded_input
|
96 |
})
|
97 |
+
prob = torch.softmax(output['logits'], dim=-1)
|
98 |
+
print(prob.shape)
|
99 |
pred = torch.max(prob, dim=-1)[1].cpu().detach().int().tolist()
|
100 |
preds += [[self.id_to_label[_p] for _p in p] for p in pred]
|
101 |
return [{"prediction": p, "label": i} for p, i in zip(preds, labels)]
|