@@ -360,17 +360,17 @@ def predict(
360
360
prob_dict_list [label_name ].extend (prob_batch_dict [task_name ])
361
361
gold_dict_list [label_name ].extend (Y .cpu ().numpy ())
362
362
363
- gold_dict : Dict [str , np . ndarray ] = {}
364
- prob_dict : Dict [str , np . ndarray ] = {}
363
+ gold_dict : Dict [str , torch . Tensor ] = {}
364
+ prob_dict : Dict [str , torch . Tensor ] = {}
365
365
366
366
for task_name in gold_dict_list :
367
- gold_dict [task_name ] = np .array (gold_dict_list [task_name ])
368
- prob_dict [task_name ] = np .array (prob_dict_list [task_name ])
367
+ gold_dict [task_name ] = torch . Tensor ( np .array (gold_dict_list [task_name ]) )
368
+ prob_dict [task_name ] = torch . Tensor ( np .array (prob_dict_list [task_name ]) )
369
369
370
370
if return_preds :
371
- pred_dict : Dict [str , np . ndarray ] = defaultdict (list )
371
+ pred_dict : Dict [str , torch . Tensor ] = defaultdict (np . ndarray )
372
372
for task_name , probs in prob_dict .items ():
373
- pred_dict [task_name ] = probs_to_preds (probs )
373
+ pred_dict [task_name ] = torch . Tensor ( probs_to_preds (probs . numpy ()) )
374
374
375
375
results = {"golds" : gold_dict , "probs" : prob_dict }
376
376
@@ -431,9 +431,9 @@ def score(
431
431
# Score and record metrics for each set of predictions
432
432
for label_name , task_name in labels_to_tasks .items ():
433
433
metric_scores = self .scorers [task_name ].score (
434
- golds = results ["golds" ][label_name ],
435
- preds = results ["preds" ][label_name ],
436
- probs = results ["probs" ][label_name ],
434
+ golds = results ["golds" ][label_name ]. numpy () ,
435
+ preds = results ["preds" ][label_name ]. numpy () ,
436
+ probs = results ["probs" ][label_name ]. numpy () ,
437
437
)
438
438
439
439
for metric_name , metric_value in metric_scores .items ():
0 commit comments