Error in neural network with one hidden layer

neural_network
#1

1 hidden layer and the nodes (n_x,n_h,n_y) = [10,16,1]

i have initialized b2 = np.zeros ((1,1)) ,

and in backward propagation db2 = 1/m*np.sum(dz2,axis =1 )

in upadate parameters b2 = b2-learning_rate*db2

so when i run these codes error shown: Data must be 1-dimensional

error is at b2 update parameter

how to solve it??
n_x = input feature
n_y = output
n_h = hidden laye nodes

0 Likes

#2

@9954953559 , put
db2 = 1/m * np.sum(dz2, axis= 1, keepdims =True)

Because in your solution by default it’s take (n[2] , ) which would not broadcast, but now it will take shape of B2 as (n[2], 1).

(n[2], ) --------- reshape -----> (n[2], 1)

0 Likes

#3

if i put keepdims = True in np.sum() , then it gives an error saying unknown attribute as keepdims . i am using python 3.4 and numpy version is 1.4 .without keepdims if i run the code it is showing error in update parameter section as data must be one dimension ??

0 Likes