From ba1351b918c96407d10608ffb3cd86911103bf26 Mon Sep 17 00:00:00 2001 From: sigpro Date: Tue, 23 Oct 2012 20:35:36 +0800 Subject: [PATCH] fix a bug in ex4 --- ex4/nnCostFunction.m | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ex4/nnCostFunction.m b/ex4/nnCostFunction.m index b7207dd..fdd8412 100644 --- a/ex4/nnCostFunction.m +++ b/ex4/nnCostFunction.m @@ -91,10 +91,10 @@ % temp = (delta_2(:,2:end)*Theta1); % temp = temp(:,2:end); % delta_1 = temp.*sigmoidGradient(X); -Theta2_grad(1,:) = delta2(1,:)./m; -Theta2_grad(2:end,:) = (lambda*Theta2(2:end,:) + delta2(2:end,:))./m; -Theta1_grad(1,:) = delta1(1,:)./m; -Theta1_grad(2:end,:) = (lambda*Theta1(2:end,:) + delta1(2:end,:))./m; +Theta2_grad = delta2./m; +Theta2_grad(:, 2:end) = (lambda*Theta2(:, 2:end) + delta2(:, 2:end))./m; +Theta1_grad = delta1./m; +Theta1_grad(:, 2:end) = (lambda*Theta1(:, 2:end) + delta1(:, 2:end))./m;