-
Notifications
You must be signed in to change notification settings - Fork 19
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
[TO_REVIEW] ConditionalTransferableComponentsAdapter Implementation #137
base: main
Are you sure you want to change the base?
[TO_REVIEW] ConditionalTransferableComponentsAdapter Implementation #137
Conversation
skada/_subspace.py
Outdated
# Define constraint function for Grassmann manifold: W^TW = I_d | ||
# def grassmann_constraint_function(W): | ||
# return np.dot(W.T, W) - np.eye(n_components) | ||
|
||
# grassmann_constraint = { | ||
# "type": "eq", | ||
# "fun": grassmann_constraint_function, | ||
# } | ||
|
||
(_, W, _, _), _ = torch_minimize( | ||
func_torch, (alpha, W, G, H), tol=self.tol, max_iter=1 | ||
) | ||
W = torch.tensor(W, dtype=torch.float64) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here any idea how to enforce the constraint to the torch minimiser ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hello, here are a couple of ideas:
-
Use the dual of the optimization problem resulting in adding the constraint to the loss in Pytorch:
min_x f(x) st g(x) = 0 <==> min_{x, lambda} f(x) + lambda * g(x)
here the constraint would be the norm of W^TW - Id -
Another idea could be to generate the matrices directly on the Grassmanian manifold:
a) geomtorch: https://geotorch.readthedocs.io/en/latest/orthogonal/grassmannian.html
b) torch: https://pytorch.org/docs/stable/generated/torch.nn.utils.parametrizations.orthogonal.html
Une autre methode, c'est de parametriser tes fonctions tq ce soit orthogonal avec
- Maybe not directly related, but here is an interesting paper with code to optimize orthogonal matrices:
https://proceedings.mlr.press/v151/ablin22a/ablin22a.pdf (code: https://github.com/pierreablin/landing)
@rflamary @antoinecollas do you have any suggestions?
Fixes: #96
Paper: https://proceedings.mlr.press/v48/gong16.pdf
Mostly eq 7-8-9-10