- 检查一下函数参数的位置,预测值和真实值位置不一样,可以参考函数定义
torch_r2score = torch_r2(pred, y)
sklearn_r2score = r2_score(y, pred)
https://pytorch.org/torcheval/main/generated/torcheval.metrics.functional.r2_score.html
Parameters:
input – Tensor of predicted values with shape of (n_sample, n_output).
target – Tensor of ground truth values with shape of (n_sample, n_output).
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)
y_true: Ground truth (correct) target values.
y_pred: Estimated target values.