-
-
Notifications
You must be signed in to change notification settings - Fork 611
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
Feature request: Modifying Dense Layer to accommodate kernel/bias constraints and kernel/bias regularisation #1389
Comments
This is just a personal impression, but my understanding is that the Flux philosophy would be to handle such options at the loss/optimization level. For example, the examples presented here https://fluxml.ai/Flux.jl/stable/models/regularisation/ shows how ad hoc constraints on parameters could be applied. Also, https://fluxml.ai/Flux.jl/stable/models/advanced/ shows how constraints could be applied through params freezing. By doing so, I think it helps keeping the control flexible and applicable to any operators without the need to load numerous arguments to each of the operator, which is a plus to the Flux experience in my opinion. |
Hi @jeremiedb I had little difficulty in understanding this |
You can pass a callback to the Typically constraints are implemented by contracting the weights to the constrained space after each update, e.g. for p in params(model)
p .= clamp(p, -2, 2)
end or reparametrizing the weights. In the latter case instead, you have to define your own layer. |
@CarloLucibello ps = Flux.params(model)
cb = function() #callback function
ps[1] .= abs.(ps[1]) # to , "say" only consider positive or absolute values of first layer
# or clamping in 0.0 and 1.0 interval
ps[1] .= clamp.(ps[1], 0.0 ,1.0)
end
cb()
@epochs args.epochs Flux.train!( loss, ps, train_data, opt, cb = cb) |
Hi,
I feel Dense layer should be more armed with arguments like kernel/weights constraints, bias constraints, kernel/weights regularisation and bias regularisation as is available in Tensorflow.
Weight constraints and bias constraints could help in avoiding overfitting
Some well-known weight/bias constraints include
NonNeg
(to make weights non-negative)MaxNorm
,MinMaxNorm
andUnitNorm
as documented athttps://keras.io/api/layers/constraints/
The text was updated successfully, but these errors were encountered: