Hypothesis matlab实现 g = 1./(1+exp(-z)); Cost function and gradient the gradient of the cost is a vector of the same length as θ matlab实现 J = 1/m * sum(-y.*log(sigmoid(X*theta))-(1-y).*log(1-sigmoid(X*theta))); grad = 1/m * X'*(sigmoid(X*theta)-y);