Skip to content

Commit 47cc97c

Browse files
authored
Update cnn.py -- Regularization function
include weights from layer 3 in regularization function instead of W1 twice ;)
1 parent facb902 commit 47cc97c

File tree

1 file changed

+1
-1
lines changed
  • assignment2/cs231n/classifiers

1 file changed

+1
-1
lines changed

assignment2/cs231n/classifiers/cnn.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ def loss(self, X, y=None):
108108
loss, dout = softmax_loss(scores, y)
109109

110110
# Add regularization
111-
loss += self.reg * 0.5 * (np.sum(self.params['W1'] ** 2) + np.sum(self.params['W2'] ** 2) + np.sum(self.params['W1'] ** 2))
111+
loss += self.reg * 0.5 * (np.sum(self.params['W1'] ** 2) + np.sum(self.params['W2'] ** 2) + np.sum(self.params['W3'] ** 2))
112112

113113
dX3, grads['W3'], grads['b3'] = affine_backward(dout, cache_forward_3)
114114
dX2 = relu_backward(dX3, cache_relu_2)

0 commit comments

Comments
 (0)