machine learning - Backward Propagation - Gradient error [Python] -


i working through andrew ng new deep learning coursera course, week2.

we supposed implement logistic regression algorithm.
stuck @ gradient code ( dw ) - giving me syntax error.

the algorithm follows:

import numpy np  def propagate(w, b, x, y):     m = x.shape[1]      = sigmoid(np.dot(w.t,x) + b )  # compute activation     cost = -(1/m)*(np.sum(np.multiply(y,np.log(a)) + np.multiply((1-y),np.log(1-a)), axis=1)          dw =(1/m)*np.dot(x,(a-y).t)     db = (1/m)*(np.sum(a-y))     assert(dw.shape == w.shape)     assert(db.dtype == float)     cost = np.squeeze(cost)     assert(cost.shape == ())      grads = {"dw": dw,              "db": db}      return grads, cost 

any ideas why keep on getting syntax error?

file "<ipython-input-1-d104f7763626>", line 32     dw =(1/m)*np.dot(x,(a-y).t)      ^ syntaxerror: invalid syntax 

in line cost = ..., missing 1 parenthesis @ end, or remove 1 after *:

# ... cost = -(1/m)*np.sum(np.multiply(y,np.log(a)) + np.multiply((1-y),np.log(1-a)), axis=1) # ... 

Comments

Popular posts from this blog

PHP and MySQL WP -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

go - golang pprof for c library code -