Skip to content

Instantly share code, notes, and snippets.

@marcopeix
Created February 26, 2019 17:00
Show Gist options
  • Save marcopeix/27c1c616af8105f4c4d68fd777942e72 to your computer and use it in GitHub Desktop.
Save marcopeix/27c1c616af8105f4c4d68fd777942e72 to your computer and use it in GitHub Desktop.
def initialize_parameters_deep(layer_dims):
parameters = {}
L = len(layer_dims) # number of layers in the network
for l in range(1, L):
parameters['W' + str(l)] = np.random.randn(layer_dims[l], layer_dims[l-1]) * 0.01
parameters['b' + str(l)] = np.zeros(shape=(layer_dims[l], 1))
assert(parameters['W' + str(l)].shape == (layer_dims[l], layer_dims[l-1]))
assert(parameters['b' + str(l)].shape == (layer_dims[l], 1))
return parameters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment