-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unnecessary overhead when calculating CCALoss #191
Comments
You're correct on the cov calls |
tl;dr you're right on the leaky relu theoretically speaking and probably practically too. I agree that all the eigenvalues should be positive semidefinite (everything is a covariance matrix, covariance matrices are PSD etc.) However sometimes they aren't numerically psd with the torch cov solver which sometimes makes things freak out, in particular when using minibatch size ~= latent dimensions (see the issues on literally all the cca implementations on GitHub). The reason the code is how it is now is that I once hypothesised before I understood the math that the leaky relu might help and maybe it does maybe it doesn't but my view now is for the original CCA loss you need minibatch size >> latent dimensions for things to work well which means in practice the eigenvalues are positive so relu==leakyrelu For all DCCA, I recommend our CCA-EY loss which is awesome give it a go and you'll get better results than the original CCA one 🫡 |
Sounds good, thanks for your speedy answer and the tip with the CCA-EY loss, I'll definitely try it out :D |
Yeah will do when I get a moment |
Alright, thank you for the great repository :D |
Greetings,
I was looking at the CCALoss' current implementation and wondered why
torch.cov
was called 3 times, when one would have sufficed. The following Covariance Matrix already containsSigmaHat11
andSigmaHat22
:SigmaHat12 = torch.cov(torch.hstack((representations[0], representations[1])).T)
I ran a simple test with artificial representations to confirm my thoughts :
And this test returns
True
for both print statements. Am I missing something or could one remove the two unnecessarytorch.cov
calls ?The
torch.nn.LeakyReLU()
call ineigvals = torch.nn.LeakyReLU()(eigvals[torch.gt(eigvals, 0)])
also seems unnecessary to me, shouldn't all values ineigvals[torch.gt(eigvals, 0)]
already be positive ?Thank you for your time and help.
Best regards,
JH
The text was updated successfully, but these errors were encountered: