Skip to content

Commit 9d65d2b

Browse files
author
Merouane Atig
committed
Try backpropagation
1 parent f7278bf commit 9d65d2b

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

mlclass-ex4/nnCostFunction.m

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,16 @@
8181
J = J + regularization;
8282

8383

84+
DELTA = zeros(size(Theta1));
85+
for t = 1:m
86+
for k = 1:num_labels
87+
yk = y(t) == k;
88+
deltak(k) = htheta(t, k) - yk;
89+
end
90+
delta_2 = Theta2' * deltak' .* sigmoidGradient(a2(t, :))';
91+
delta_2 = delta_2(2:end);
92+
DELTA = DELTA + delta_2 * a1(t, :);
93+
end
8494

8595

8696

0 commit comments

Comments
 (0)