xxgege / StableNet

Official repository for CVPR21 paper "Deep Stable Learning for Out-Of-Distribution Generalization".
184 stars 43 forks source link

Some Questions about loss_reweighting.py #10

Open believewhat opened 2 years ago

believewhat commented 2 years ago

Hello, author, in the cov function of loss_reweighting.py. I think there is a little different with the definition in the paper: Your code: cov = torch.matmul((w x).t(), x) Your paper: T}USG}2ICE}E02SL 84(1O1 Why the code is not cov = torch.matmul((w x).t(), w * x) Thank you very much.

allenwang2333 commented 1 year ago

I'm also very confused at that part. The cov in code is calculating the covariance not of the projection to RFF space, but the original space. I think that u and v here means projection to the RFF space.

zmcwsd commented 1 year ago

i think you are right,i agree

TianmingXie commented 1 year ago

I think the authors calculate the covariance matrix through Cov(X, Y)=E(XY)-E(X)E(Y), but not following the formula in the paper.

gittea-rpi commented 1 month ago

The equation in the paper is incorrect, the one used in the code is correct. Cov_w(X,Y) = E_w(XY^T) - E_w(X)E_w(Y)^T, which is computed in the code. (E_w here means the weighted expectation).