-
Notifications
You must be signed in to change notification settings - Fork 3
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
Change design for dispatch #22
Conversation
Reduces duplication and is probably a more natural way to implement this package extension.
Provide richer info to _gcp so we can dispatch at that level. Preparing the way for having various algorithms.
Codecov ReportAll modified lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #22 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 5 5
Lines 107 106 -1
=========================================
- Hits 107 106 -1
☔ View full report in Codecov by Sentry. |
Implement fall-back using `UserDefinedLoss`.
One more TODO remaining: GCPDecompositions.jl/src/gcp-opt.jl Lines 48 to 55 in 4b5431a
Will require reworking how we do the testing since we currently use that signature. For example: GCPDecompositions.jl/test/items/gcp-opt.jl Lines 51 to 58 in 4b5431a
Since this would affect ongoing work in #20, can address this in a separate PR after #20 is merged. Should probably rethink how we do this testing anyway. [UPDATE 10/12/2023: now tracking this TODO in #23] |
Currently we define two methods for
gcp
:GCPDecompositions.jl/src/gcp-opt.jl
Lines 18 to 25 in 6c3c18d
GCPDecompositions.jl/ext/LossFunctionsExt.jl
Lines 8 to 15 in 6c3c18d
These call the following
_gcp
method:GCPDecompositions.jl/src/gcp-opt.jl
Line 55 in 6c3c18d
Idea: unify the two
gcp
methods and pass the inputs directly to_gcp
so we just havegcp(X, r, loss = LeastSquaresLoss()) = _gcp(X, r, loss)
. Handle LossFunctions.jl losses by adding methods forvalue
,deriv
anddomain
.With this design:
gcp
provides the user-friendly interface and handles defaults_gcp
does not handle defaults - it only implements the algorithmsSeparating concerns this way has some potential benefits:
LossFunctionsExt
- don't need to duplicate code for defaults, etc._gcp
methods, e.g., ALS for least-squares (ALS doesn't apply to other loss functions), etc.