initialization - Initializing 1 Layer Neural Network Parameters -


i trying initialize following nn model

enter image description here

def initialize_parameters(n_x, n_h, n_y):

w1 = np.random.randn(4,2) *0.01 b1 = np.zeros((4,1)) w2 = np.random.randn(1,4) * 0.01 b2 = np.zeros((1,1))   assert (w1.shape == (n_h, n_x)) assert (b1.shape == (n_h, 1)) assert (w2.shape == (n_y, n_h)) assert (b2.shape == (n_y, 1))  parameters = {"w1": w1,               "b1": b1,               "w2": w2,               "b2": b2}  return parameters 

my output comes out :

w1 = [[-0.00416758 -0.00056267]  [-0.02136196  0.01640271]  [-0.01793436 -0.00841747]  [ 0.00502881 -0.01245288]] b1 = [[ 0.]  [ 0.]  [ 0.]  [ 0.]] w2 = [[-0.01057952 -0.00909008  0.00551454  0.02292208]] b2 = [[ 0.]] 

whereas correct answer should :

w1  [[-0.00416758 -0.00056267] [-0.02136196 0.01640271] [-0.01793436 -0.00841747] [ 0.00502881 -0.01245288]] b1  [[ 0.] [ 0.] [ 0.] [ 0.]] w2  [[-0.01057952 -0.00909008 0.00551454 0.02292208]] b2  [[ 0.]] 

w1, , b1 wrong, cannot make work other way. newbie here. in advance!

it doesn't accept because hardcoded values f.ex. 4 , 2 in np.random.randn(4,2) *0.01. instead use arguments n_h, n_x.


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -