TP += ((outputs_compare==1) & (mask_train2numpy==1)).sum()
TN += ((outputs_compare==0) & (mask_train2numpy==1)).sum()
FN += ((outputs_compare==0) & (mask_train2numpy==1)).sum()
FP += ((outputs_compare==1) & (mask_train2numpy==0)).sum()
p = TP / (TP + FP)
r = TP /(TP + FN)
F1 = 2 * r * p / (r + p)
acc = (TP + TN) / (TP + TN + FP + FN)

@ptrblck  ,thank you, I find my code’s problem ,It is a  RuntimeWarning,not error ,I think may be arithmetic overflow .It should be
TN += ((outputs_compare==0) & (mask_train2numpy==0)).sum()