Metrics 函数用于计算模型的准确率。它通过比较真实标签和预测标签的值来确定正确预测的数量,然后计算准确率。准确率是正确预测的数量除以总样本数量的比例。

def Metrics(true_label,pred_label):
    print('Evaluation...')
    all_prediction = pred_label.cpu()
    all_label = true_label.cpu()
    correct_num = (all_label == all_prediction).sum().item()
    test_acc = correct_num / (len(true_label))
    return correct_num, test_acc
Metrics 函数:计算模型准确率

原文地址: https://www.cveoy.top/t/topic/ffrg 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录