-
-
Notifications
You must be signed in to change notification settings - Fork 612
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
Added deprecation warning to Dense(in,out,act,initW,initb) #722
Added deprecation warning to Dense(in,out,act,initW,initb) #722
Conversation
src/layers/basic.jl
Outdated
@@ -72,6 +74,7 @@ Dense(W, b) = Dense(W, b, identity) | |||
|
|||
function Dense(in::Integer, out::Integer, σ = identity; | |||
initW = glorot_uniform, initb = zeros) | |||
depwarn("Dense(in,out,σ,initW,initb) is deprecated; use Dense(W,b) instead",:Dense) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can't just deprecate the whole method here. The tricky part is that keyword arguments are not counted in multiple dispatch.
One possible solution (not sure if it works)
- change
initW = glorot_uniform
toinitW = nothing
- manual check before initialization
if initW is nothing
initW = glorot_uniform;
else
depwarn
end
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see...My bad...I'll fix this accordingly...
Looks like this strategy works. Now you need to have a look at the codebase and deprecate other functions such as BTW, it might be useful to provide a link to #671 as a comment alongside your |
I suppose that the other layers do not have this issue and this mostly pertained to the Dense layer. |
It's not about single init keyword, it's about consistency. If you deprecate |
Let's get the I think the @deprecate Dense(in::Integer, out::Integer; initW = ...) = Dense(initW(out, in), ...) which separates the deprecated code from the new code nicely, and gives a clearer instruction to the user. |
@MikeInnes julia> foo(a,b;k=1) = println()
foo (generic function with 1 method)
julia> @deprecate foo(a,b;k=1) foo(a,b)
foo (generic function with 1 method)
julia> foo(1,2)
┌ Warning: `foo(a, b; k=1)` is deprecated, use `foo(a, b)` instead.
│ caller = top-level scope at none:0
└ @ Core none:0 https://github.com/JuliaDocs/Documenter.jl/blob/c59fe92f880e7acfbf2610fed0c70dc364e4c3a0/src/Documenter.jl#L473-L513 is an example of such deprecation work. |
It actually works if you do it the other way around: julia> @deprecate foo(a,b;k=1) foo(a,b)
foo (generic function with 1 method)
julia> foo(a,b;k=1) = println()
foo (generic function with 1 method)
julia> foo(1, 2) But to be fair this probably still results in a method warning. Another option is to use a more specific signature for the non-deprecated method. It might be best just to stick with the if-then approach though. |
If it's all about deprecating |
initW = glorot_uniform, initb = zeros) | ||
initW = nothing, initb = nothing) | ||
if initW != nothing || initb != nothing | ||
depwarn("Dense(in,out,σ,initW,initb) is deprecated; use Dense(W,b) instead",:Dense) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think "keyword argument `initW` is deprecated; use `Dense(W,b)` to initialize" is more descriptive to the current one.
closing as we are going in a different direction with #1440 |
Addresses issue #671 .
@MikeInnes is this what was needed?