Skip to content

Commit

Permalink
Merge pull request #115 from PumasAI/rngkwargdefault
Browse files Browse the repository at this point in the history
`init_params!` should always have a default kwarg, rename tuple version `_init_params!`
  • Loading branch information
chriselrod authored Sep 30, 2022
2 parents 6fbf2b0 + 76f182a commit 906b70b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "SimpleChains"
uuid = "de6bee2f-e2f4-4ec7-b6ed-219cc6f6e9e5"
authors = ["Chris Elrod <[email protected]> and contributors"]
version = "0.3.3"
version = "0.3.4"

[deps]
ArrayInterface = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9"
Expand Down
10 changes: 5 additions & 5 deletions src/simple_chain.jl
Original file line number Diff line number Diff line change
Expand Up @@ -388,16 +388,16 @@ Randomly initializes parameter vector `p` with input dim `id`. Input dim does no
See the documentation of the individual layers to see how they are initialized, but it is generally via (Xavier) Glorot uniform or normal distributions.
"""
function init_params!(
chn::SimpleChain, x::AbstractVector, id = nothing; rng::AbstractRNG
chn::SimpleChain, x::AbstractVector, id = nothing; rng::AbstractRNG = local_rng()
)
GC.@preserve x init_params!(chn.layers, pointer(x), chain_input_dims(chn, id), rng)
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)
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)
_init_params!(Base.tail(layers), p, od, rng)
end
init_params!(::Tuple{}, p::Ptr, _, ::AbstractRNG) = nothing
_init_params!(::Tuple{}, p::Ptr, _, ::AbstractRNG) = nothing
function init_params(
Λ::SimpleChain,
id::Union{Nothing,InputDim} = nothing,
Expand Down

2 comments on commit 906b70b

@chriselrod
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/69272

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.3.4 -m "<description of version>" 906b70b3beb196f6b5721709cf3aaad2dcc3ab8a
git push origin v0.3.4

Please sign in to comment.