Mercurial > hg > machine-learning-hw4
changeset 7:7351a5c62d4d
Add regularisation
author | Jordi Gutiérrez Hermoso <jordigh@octave.org> |
---|---|
date | Fri, 11 Nov 2011 17:58:56 -0500 |
parents | e09973b9190f |
children | 5c236ac72938 |
files | nnCostFunction.m |
diffstat | 1 files changed, 4 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/nnCostFunction.m +++ b/nnCostFunction.m @@ -59,6 +59,10 @@ permute ([one_vec, a1], [3, 2, 1])), 3)/m; + ## Add regularisation terms + Theta2_grad(:, 2:end) += Theta2(:, 2:end)*lambda/m; + Theta1_grad(:, 2:end) += Theta1(:, 2:end)*lambda/m; + grad = [Theta1_grad(:) ; Theta2_grad(:)]; endfunction