change mabel score to probability
Browse files
__pycache__/bert_for_sequence_classification.cpython-37.pyc
CHANGED
|
Binary files a/__pycache__/bert_for_sequence_classification.cpython-37.pyc and b/__pycache__/bert_for_sequence_classification.cpython-37.pyc differ
|
|
|
__pycache__/bibert_multitask_classification.cpython-37.pyc
CHANGED
|
Binary files a/__pycache__/bibert_multitask_classification.cpython-37.pyc and b/__pycache__/bibert_multitask_classification.cpython-37.pyc differ
|
|
|
bibert_multitask_classification.py
CHANGED
|
@@ -41,13 +41,13 @@ class BiBert_MultiTaskPipeline(Pipeline):
|
|
| 41 |
scores = softmax(outputs)
|
| 42 |
|
| 43 |
if top_k == 1 and _legacy:
|
| 44 |
-
return {"label": self.model.config.id2label[scores.argmax().item()], "
|
| 45 |
|
| 46 |
dict_scores = [
|
| 47 |
-
{"label": self.model.config.id2label[i], "
|
| 48 |
]
|
| 49 |
if not _legacy:
|
| 50 |
-
dict_scores.sort(key=lambda x: x["
|
| 51 |
if top_k is not None:
|
| 52 |
dict_scores = dict_scores[:top_k]
|
| 53 |
return dict_scores
|
|
|
|
| 41 |
scores = softmax(outputs)
|
| 42 |
|
| 43 |
if top_k == 1 and _legacy:
|
| 44 |
+
return {"label": self.model.config.id2label[scores.argmax().item()], "probability": scores.max().item()}
|
| 45 |
|
| 46 |
dict_scores = [
|
| 47 |
+
{"label": self.model.config.id2label[i], "probability": score.item()} for i, score in enumerate(scores)
|
| 48 |
]
|
| 49 |
if not _legacy:
|
| 50 |
+
dict_scores.sort(key=lambda x: x["probability"], reverse=True)
|
| 51 |
if top_k is not None:
|
| 52 |
dict_scores = dict_scores[:top_k]
|
| 53 |
return dict_scores
|