Skip to content
This repository was archived by the owner on May 13, 2023. It is now read-only.

Commit 2e65746

Browse files
authored
Update svm_gradient.py
1 parent 780f6ba commit 2e65746

File tree

1 file changed

+4
-18
lines changed

1 file changed

+4
-18
lines changed

svm_gradient.py

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,9 @@ def svm_gradient(w, b, x, y, C):
1818
1919
"""
2020

21-
grad_w = 0 # gradient
22-
grad_b = 0 # loss
23-
24-
25-
#######################################################################
26-
# TODO: #
27-
# Compute the gradient for a particular choice of w and b. #
28-
# Compute the partial derivatives and set grad_w and grad_b to the #
29-
# partial derivatives of the cost w.r.t. both parameters #
30-
# #
31-
#######################################################################
32-
33-
lambda_ = 1/C
21+
grad_w = 0
22+
grad_b = 0
23+
lambda_ = 1/C
3424
N = x.size
3525
normw = np.linalg.norm(w)
3626
w_t = np.transpose(w)
@@ -48,8 +38,4 @@ def svm_gradient(w, b, x, y, C):
4838
var2[preds] = 0
4939
grad_b = C * var2.sum()
5040

51-
52-
#######################################################################
53-
# END OF YOUR CODE #
54-
#######################################################################
55-
return grad_w, grad_b
41+
return grad_w, grad_b

0 commit comments

Comments
 (0)