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 L2/L1 regularization #179

Merged
merged 7 commits into from
Jul 19, 2021
Merged

Add L2/L1 regularization #179

merged 7 commits into from
Jul 19, 2021

Conversation

ablaom
Copy link
Collaborator

@ablaom ablaom commented Jul 10, 2021

This PR:

@ToucheSir Further to Julia Discourse discussion, no change was actually necessary to the coretrain! loop to add regularization. It's just that the loss function passed to this loop now depends on the chain (Flux model), when L2/L1 regularisation parameters are non-trivial. To avoid the array mutation error I needed to avoid broadcasting in the computation of the penalty here. Any performance suggestions re these two bits of code appreciated.

@codecov-commenter
Copy link

codecov-commenter commented Jul 10, 2021

Codecov Report

Merging #179 (67409a5) into dev (a40bdfd) will decrease coverage by 0.14%.
The diff coverage is 95.12%.

Impacted file tree graph

@@            Coverage Diff             @@
##              dev     #179      +/-   ##
==========================================
- Coverage   90.74%   90.59%   -0.15%     
==========================================
  Files           8        9       +1     
  Lines         216      234      +18     
==========================================
+ Hits          196      212      +16     
- Misses         20       22       +2     
Impacted Files Coverage Δ
src/types.jl 85.71% <0.00%> (-14.29%) ⬇️
src/common.jl 96.77% <100.00%> (+0.22%) ⬆️
src/core.jl 90.00% <100.00%> (-0.79%) ⬇️
src/penalized_losses.jl 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a40bdfd...67409a5. Read the comment docs.

@ablaom ablaom changed the title Add regularization Add L2/L1 regularization Jul 10, 2021
src/penalized_losses.jl Outdated Show resolved Hide resolved
@ablaom
Copy link
Collaborator Author

ablaom commented Jul 13, 2021

@ayush-1506 Would you like to review this PR? I've tested it locally on a GPU.

@DilumAluthge How do I put the GPU tests back for PR's onto dev?

@ayush-1506
Copy link
Member

@ablaom Sure, please give me a day.

Copy link
Member

@ayush-1506 ayush-1506 left a comment

Choose a reason for hiding this comment

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

Just one small question, everything else looks great.

@@ -43,48 +43,53 @@ end
true_rng(model) = model.rng isa Integer ? MersenneTwister(model.rng) : model.rng

function MLJModelInterface.fit(model::MLJFluxModel,
verbosity::Int,
verbosity,
Copy link
Member

Choose a reason for hiding this comment

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

Please correct me if I'm wrong, but verbosity should is still Int, right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, but you no longer need to explicitly type it. There used to be a type ambiguity that required the type annotation but that is now long gone.

@ablaom ablaom merged commit a46aab1 into dev Jul 19, 2021
@ablaom ablaom deleted the add-regularization2 branch July 19, 2021 02:10
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.

Regularisation parameters alpha and lambda are not used
4 participants