Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.97 KB | None | 0 0
  1. def initialization(conf):
  2.     """Initialize the parameters of the network.
  3.  
  4.    Args:
  5.        layer_dimensions: A list of length L+1 with the number of nodes in each layer, including
  6.                          the input layer, all hidden layers, and the output layer.
  7.    Returns:
  8.        params: A dictionary with initialized parameters for all parameters (weights and biases) in
  9.                the network.
  10.    """
  11.     params = {}
  12.     index = 1
  13.     # Skip first element by using 1:
  14.     for layerdim in conf['layer_dimensions'][1:]:
  15.         variance = np.sqrt(2 / conf['layer_dimensions'][index - 1])
  16.         # Mean is automatically set to 0, so I don't have to specify np.random.normal(mean, var, size)
  17.         params['W_' + str(index)] = np.random.normal(scale=variance,
  18.                                                      size=(conf['layer_dimensions'][index - 1], layerdim))
  19.         params['b_' + str(index)] = np.zeros(layerdim)
  20.         index += 1
  21.     return params
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement