Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
hackassin
GitHub Repository: hackassin/Coursera-Machine-Learning
Path: blob/master/Week 5/Programming Assignment - 4/machine-learning-ex4/ex4/sigmoidGradient.m
864 views
1
function g = sigmoidGradient(z)
2
%SIGMOIDGRADIENT returns the gradient of the sigmoid function
3
%evaluated at z
4
% g = SIGMOIDGRADIENT(z) computes the gradient of the sigmoid function
5
% evaluated at z. This should work regardless if z is a matrix or a
6
% vector. In particular, if z is a vector or matrix, you should return
7
% the gradient for each element.
8
9
g = zeros(size(z));
10
11
% ====================== YOUR CODE HERE ======================
12
% Instructions: Compute the gradient of the sigmoid function evaluated at
13
% each value of z (z can be a matrix, vector or scalar).
14
g = sigmoid(z).*(1 - sigmoid(z));
15
% =============================================================
16
end
17
18