Skip to content

sparsity regularisation #235

Answered by mkunesch
renjithravindran asked this question in Q&A
Discussion options

You must be logged in to vote

Hi! Thanks a lot for the question!

The optax.masked wrapper can be used to transform only a subset of parameters using a masking function. The docstring of optax.masked has an example with L2 regularisation (using add_decayed_weights). In the case of weight decay using a mask is so common that add_decayed_weights has a mask option, which uses optax.masked under the hood.

As far as I am aware, optax currently does not have a gradient transformation for L1 regularisation but this should be easy to implement by mirroring what happens in the L2 case (optax.add_decayed_weights). We should definitely add the L1 functionality too though; would you be keen to implement it and file a PR? No worrie…

Replies: 1 comment 8 replies

Comment options

You must be logged in to vote
8 replies
@renjithravindran
Comment options

@mkunesch
Comment options

@renjithravindran
Comment options

@mkunesch
Comment options

@renjithravindran
Comment options

Answer selected by renjithravindran
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants