Skip to content
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

Add warm restart to AJDC #196

Merged
merged 5 commits into from Aug 17, 2022
Merged

Conversation

qbarthelemy
Copy link
Member

@qbarthelemy qbarthelemy commented Aug 11, 2022

This PR enhances AJDC when used for group BBS (gBSS): it allows to refine group sources for a specific subject, using an initial diagonalizer.

  • Add parameter 'init' to ajd_pham and rjd to allow warm restart, and complete tests;
  • Add a warning if 'dim_red' is let to None in AJDC, and add key 'warm_restart' for dimension reduction, and update tests.

pyriemann/spatialfilters.py Outdated Show resolved Hide resolved
@@ -20,7 +20,7 @@ def _get_normalized_weight(sample_weight, data):
return normalized_weight


def rjd(X, eps=1e-8, n_iter_max=1000):
def rjd(X, *, init=None, eps=1e-8, n_iter_max=1000):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is technically an API change but I think it's save to do.

pyriemann/utils/ajd.py Outdated Show resolved Hide resolved
pyriemann/utils/ajd.py Show resolved Hide resolved
pyriemann/utils/ajd.py Outdated Show resolved Hide resolved
aux = 1./np.sqrt(np.abs(np.diag(Raux)))
W_est = np.dot(np.diag(aux), W_est)
aux = 1. / np.sqrt(np.abs(np.diag(Raux)))
W_est = np.diag(aux) @ W_est
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use broadcasting if you can. Every time I see a np.diag in numpy my brain produces a strong ERP ;)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. I try to remove np.dot and np.diag when I can.
But I only improve the code when I’m sure to break nothing.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uwedge seems deep, I couldn't think of a way to get rid of the np.diag nicely.

@sylvchev
Copy link
Member

good for me, I'll merge if you're ok

@sylvchev
Copy link
Member

Thanks a lot Quentin!

@sylvchev sylvchev merged commit baccd8f into pyRiemann:master Aug 17, 2022
@qbarthelemy qbarthelemy deleted the ajdc_warm_restart branch August 17, 2022 14:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants