Thanks to visit codestin.com
Credit goes to github.com

Skip to content

EFF Speed-up MiniBatchDictionaryLearning by avoiding multiple validation - #25490

Merged
jjerphan merged 5 commits into
scikit-learn:mainfrom
jeremiedbb:less-validation-sparse-coding
Mar 7, 2023
Merged

EFF Speed-up MiniBatchDictionaryLearning by avoiding multiple validation#25490
jjerphan merged 5 commits into
scikit-learn:mainfrom
jeremiedbb:less-validation-sparse-coding

Conversation

@jeremiedbb

@jeremiedbb jeremiedbb commented Jan 26, 2023

Copy link
Copy Markdown
Member

MinibatchDictionaryLearning calls public functions that call public classes themselves. We end up validating the parameters and the input/dict twice per minibatch. When the batch size is large it has barely no impact but for small batch sizes it can be very detrimental.

For instance, here's a profiling result in the extreme case batch_size=1
prof3

This PR removes the first one. It's a param validation coming from sparse_encode. The profiling now gives
prof4
the first block is gone. I intend to deal with the other ones in follow up PRs

@jeremiedbb

Copy link
Copy Markdown
Member Author

I opened an alternative in #25493, which involves a lot less refactoring.

@ogrisel ogrisel left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think this refactoring can make sense whether or not we merge #25493. WDYT?

@jeremiedbb

Copy link
Copy Markdown
Member Author

Well now that it's done :)

@ogrisel ogrisel added the Waiting for Second Reviewer First reviewer is done, need a second one! label Feb 7, 2023

@jjerphan jjerphan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice observation, @jeremiedbb! This LGTM.

I just have one remark. I also think we can merge this PR independently from #25493 as @ogrisel mentioned in #25490 (review) once a changelog entry is added. What do you think?

Comment thread sklearn/decomposition/_dict_learning.py
@jeremiedbb

Copy link
Copy Markdown
Member Author

I added a what's new entry. Yes, let's merge this one first.

@jjerphan
jjerphan merged commit 408f561 into scikit-learn:main Mar 7, 2023
@jeremiedbb
jeremiedbb deleted the less-validation-sparse-coding branch September 3, 2026 16:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants