function g = sigmoidGradient(z) % computes the gradient of the sigmoid function. This should work regardless % if z is a matrix or vector. In particular, if z is a vector or matrix, you % should retur the gradient for each element. g = zeros(size(z)); g=sigmoid(z).*(1.0 -sigmoid(z));