sigmoidGradient.m 691 B

12345678910111213141516171819202122232425262728293031323334
  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. x = sigmoid(z);
  9. g = x .* (1 - x);
  10. % ====================== YOUR CODE HERE ======================
  11. % Instructions: Compute the gradient of the sigmoid function evaluated at
  12. % each value of z (z can be a matrix, vector or scalar).
  13. % =============================================================
  14. end