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 documentation for L1/L2 penalties #151

Open
era127 opened this issue Aug 9, 2023 · 1 comment
Open

Add documentation for L1/L2 penalties #151

era127 opened this issue Aug 9, 2023 · 1 comment

Comments

@era127
Copy link

era127 commented Aug 9, 2023

Would it be possible to add documentation to the simple mlp example to show how to add the L1 and L2 penalties. Thanks!

@jmsull
Copy link

jmsull commented Aug 18, 2023

You can do it like this:

using SimpleChains
sc = SimpleChain(
    static(1),
    TurboDense{true}(tanh, 128), 
    TurboDense{false}(identity, 1), 
    )
p = SimpleChains.init_params(sc);
G = SimpleChains.alloc_threaded_grad(sc); 

Y = # some data...
λ = # some penalty...
sc_reg = FrontLastPenalty(SimpleChains.add_loss(sc, SquaredLoss(Y)),
                                    L2Penalty(λ), L2Penalty(λ) ) 
    

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

No branches or pull requests

2 participants