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

init_params! inconsistent call signature cause trouble #114

Open
korsbo opened this issue Sep 29, 2022 · 3 comments
Open

init_params! inconsistent call signature cause trouble #114

korsbo opened this issue Sep 29, 2022 · 3 comments
Labels
bug Something isn't working

Comments

@korsbo
Copy link
Member

korsbo commented Sep 29, 2022

In some places init_params! is defined with rng as a kwarg and in some places it's an arg.

@korsbo korsbo changed the title init_params init_params! inconsistent call signature cause trouble Sep 29, 2022
@korsbo
Copy link
Member Author

korsbo commented Sep 29, 2022

function init_params!(
chn::SimpleChain, x::AbstractVector, id = nothing; rng::AbstractRNG
)
GC.@preserve x init_params!(chn.layers, pointer(x), chain_input_dims(chn, id), rng)
return x
end
function init_params!(layers::Tuple, p::Ptr, id, rng::AbstractRNG)
p, od = init_params!(first(layers), p, id, rng)
init_params!(Base.tail(layers), p, od, rng)
end

@korsbo korsbo added the bug Something isn't working label Sep 29, 2022
@korsbo
Copy link
Member Author

korsbo commented Sep 29, 2022

I'm not even sure that this was my original problem. I was hitting the error that rng was an undefined kwarg. Maybe just add a default to that kw?

@chriselrod
Copy link
Contributor

chriselrod commented Sep 29, 2022

Do you want me to rename those methods _init_params instead? Users should be calling the ::Tuple methods.
The ::Tuple methods have an rng as a positional argument, and the API ones that take an AbstractChain have it as a kwarg.

Any exceptions to that are a bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants