Skip to content

Instantly share code, notes, and snippets.

@PyDataBlog
Last active October 11, 2020 11:00
Show Gist options
  • Select an option

  • Save PyDataBlog/adde4a97494bc44135f3fd298bc01a5f to your computer and use it in GitHub Desktop.

Select an option

Save PyDataBlog/adde4a97494bc44135f3fd298bc01a5f to your computer and use it in GitHub Desktop.
"""
Funtion to initialise the parameters or weights of the desired network.
"""
function initialise_model_weights(layer_dims, seed)
params = Dict()
# Build a dictionary of initialised weights and bias units
for l=2:length(layer_dims)
params[string("W_", (l-1))] = rand(StableRNG(seed), layer_dims[l], layer_dims[l-1]) * sqrt(2 / layer_dims[l-1])
params[string("b_", (l-1))] = zeros(layer_dims[l], 1)
end
return params
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment