Friday, June 12, 2015

Neural Network Learning : Machine Learning

function g = sigmoidGradient(z)
%SIGMOIDGRADIENT returns the gradient of the sigmoid function%evaluated at z% g = SIGMOIDGRADIENT(z) computes the gradient of the sigmoid function% evaluated at z. This should work regardless if z is a matrix or a% vector. In particular, if z is a vector or matrix, you should return% the gradient for each element.
g = zeros(size(z));
% ====================== YOUR CODE HERE ======================% Instructions: Compute the gradient of the sigmoid function evaluated at% each value of z (z can be a matrix, vector or scalar).
sigmoidZ = zeros(size(z, 1), size(z, 2));
for i=1:size(sigmoidZ, 1)
for j=1:size(sigmoidZ, 2)
sigmoidZ(i,j) = sigmoid(z(i,j));
endend
oneMinus = 1-sigmoidZ;
for i=1:size(g,1)
for j=1:size(g,2)
g(i,j) = sigmoidZ(i,j)*oneMinus(i, j);
endend% =============================================================end