- 检查一下函数参数的位置,预测值和真实值位置不一样,可以参考函数定义
torch_r2score = torch_r2(pred, y)
sklearn_r2score = r2_score(y, pred)
https://pytorch.org/torcheval/main/generated/torcheval.metrics.functional.r2_score.html
https://scikit-learn.org/stable/modules/generated/sklearn.metrics.r2_score.html
sklearn.metrics.r2_score(y_true, y_pred, *, sample_weight=None, multioutput=‘uniform_average’, force_finite=True)