Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def initialization(conf):
- """Initialize the parameters of the network.
- Args:
- layer_dimensions: A list of length L+1 with the number of nodes in each layer, including
- the input layer, all hidden layers, and the output layer.
- Returns:
- params: A dictionary with initialized parameters for all parameters (weights and biases) in
- the network.
- """
- params = {}
- index = 1
- # Skip first element by using 1:
- for layerdim in conf['layer_dimensions'][1:]:
- variance = np.sqrt(2 / conf['layer_dimensions'][index - 1])
- # Mean is automatically set to 0, so I don't have to specify np.random.normal(mean, var, size)
- params['W_' + str(index)] = np.random.normal(scale=variance,
- size=(conf['layer_dimensions'][index - 1], layerdim))
- params['b_' + str(index)] = np.zeros(layerdim)
- index += 1
- return params
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement