Question: Need help code this in python Here is the given code def gradient(X, y, w, b): # Input: # X: nxd matrix # y: n-dimensional
Need help code this in python

Here is the given code
def gradient(X, y, w, b): # Input: # X: nxd matrix # y: n-dimensional vector with labels (+1 or -1) # w: d-dimensional vector # b: a scalar bias term # Output: # wgrad: d-dimensional vector with gradient # bgrad: a scalar with gradient n, d = X.shape wgrad = np.zeros(d) bgrad = 0.0 # YOUR CODE HERE
return wgrad, bgrad
Part Four: Compute Gradient (Graded] Now, verify that the gradient of the log-loss with respect to the weight vector is: ON LL(X. y.w.b) -yo-y(wx+b)x dw ab aN LLX,y,w.b) -20-(w'x + b). Implement the function gradient which returns the first derivative with respect to w, b for a given x, y, w, b. Hint: remember that you derived earlier that o' (2) = o(z)(1 - o(z))
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
