cuteboyqq / skip-GANOMALY-Pytorch

GANomaly, Skip-Ganomaly, Skip-CBAM-GANomaly, pytorch, CIFAR10, MNIST
7 stars 0 forks source link

About code #4

Open ChenSiwiI opened 1 year ago

ChenSiwiI commented 1 year ago

I would like to ask this loss _ th, change the size, acc does not change, and different loss values, normal acc and abnormal acc values represent the meaning ?

def Analysis_Accuracy_UserDefineLossTH(self, normal_count_list,abnormal_count_list,loss_th=2.0, user_loss_list=None): show_log = False normal_correct_cnt = 0 total_normal_cnt = 0 for i in range(len(normal_count_list)): total_normal_cnt+=normal_count_list[i] if user_loss_list[i] < loss_th: normal_correct_cnt+=normal_count_list[i] if show_log: print('normal_correct_cnt: {}'.format(normal_correct_cnt)) print('total_normal_cnt: {}'.format(total_normal_cnt)) if total_normal_cnt == 0: normal_acc = 0.0 else: normal_acc = float(normal_correct_cnt/total_normal_cnt)

    total_abnormal_cnt = 0
    abnormal_correct_cnt = 0
    for i in range(len(abnormal_count_list)):
        total_abnormal_cnt+=abnormal_count_list[i]
        if user_loss_list[i] >= loss_th:
            abnormal_correct_cnt+=abnormal_count_list[i]
    if show_log:
        print('abnormal_correct_cnt : {}'.format(abnormal_correct_cnt))
        print('total_abnormal_cnt: {}'.format(total_abnormal_cnt))
    if total_abnormal_cnt==0:
        abnormal_acc = 0
    else:
        abnormal_acc = float(abnormal_correct_cnt / total_abnormal_cnt)

    return normal_acc,abnormal_acc