Skip to content

Commit

Permalink
Use np.sum to compute sum of dic values
Browse files Browse the repository at this point in the history
  • Loading branch information
maldil authored Jun 26, 2022
1 parent eea2986 commit ef228e7
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions a00_Bert/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,7 @@ def compute_f1_macro_use_TFFPFN(label_dict):
TP,FP,FN=tuplee
f1_score_onelabel=compute_f1(TP,FP,FN,'macro')
f1_dict[label]=f1_score_onelabel
f1_score_sum=0.0
for label,f1_score in f1_dict.items():
f1_score_sum=f1_score_sum+f1_score
f1_score_sum=np.sum(f1_dict.values())
f1_score=f1_score_sum/float(num_classes)
return f1_score

Expand Down Expand Up @@ -249,4 +247,4 @@ def compute_confuse_matrix_batch(y_targetlabel_list,y_logits_array,label_dict,na
"""
for i,y_targetlabel_list_single in enumerate(y_targetlabel_list):
label_dict=compute_confuse_matrix(y_targetlabel_list_single,y_logits_array[i],label_dict,name=name)
return label_dict
return label_dict

0 comments on commit ef228e7

Please sign in to comment.