Need a unique gift idea?
A Pastebin account makes a great Christmas gift
SHARE
TWEET

Untitled

a guest Sep 20th, 2018 62 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
 
  1. def initialize_parameters_zeros(layers_dims):
  2.     np.random.seed(1)              
  3.     parameters = {}                
  4.     L = len(layers_dims)            
  5.  
  6.     for l in range(1, L):
  7.         parameters["W" + str(l)] = np.zeros(
  8.             (layers_dims[l], layers_dims[l - 1]))
  9.         parameters["b" + str(l)] = np.zeros((layers_dims[l], 1))
  10.  
  11.     return parameters
  12.  
  13.  
  14. def initialize_parameters_random(layers_dims):
  15.     np.random.seed(1)              
  16.     parameters = {}                
  17.     L = len(layers_dims)            
  18.  
  19.     for l in range(1, L):
  20.         parameters["W" + str(l)] = np.random.randn(
  21.             layers_dims[l], layers_dims[l - 1]) * 10
  22.         parameters["b" + str(l)] = np.zeros((layers_dims[l], 1))
  23.  
  24.     return parameters
  25.  
  26.  
  27. def initialize_parameters_he_xavier(layers_dims, initialization_method="he"):
  28.     np.random.seed(1)              
  29.     parameters = {}                
  30.     L = len(layers_dims)            
  31.  
  32.     if initialization_method == "he":
  33.         for l in range(1, L):
  34.             parameters["W" + str(l)] = np.random.randn(
  35.                 layers_dims[l],
  36.                 layers_dims[l - 1]) * np.sqrt(2 / layers_dims[l - 1])
  37.             parameters["b" + str(l)] = np.zeros((layers_dims[l], 1))
  38.     elif initialization_method == "xavier":
  39.         for l in range(1, L):
  40.             parameters["W" + str(l)] = np.random.randn(
  41.                 layers_dims[l],
  42.                 layers_dims[l - 1]) * np.sqrt(1 / layers_dims[l - 1])
  43.             parameters["b" + str(l)] = np.zeros((layers_dims[l], 1))
  44.  
  45.     return parameters
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top