用matlab实现梯度下降算法(gradient descent).看的斯坦福的machine learning 课程,作业任务是用matlab实现梯度下降算法,theta(j)=theta-alpha*(theta(j)'s derivative of costFunction).实现之后,costFunction应该是逐渐
来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/29 14:54:17
用matlab实现梯度下降算法(gradient descent).看的斯坦福的machine learning 课程,作业任务是用matlab实现梯度下降算法,theta(j)=theta-alpha*(theta(j)'s derivative of costFunction).实现之后,costFunction应该是逐渐
用matlab实现梯度下降算法(gradient descent).
看的斯坦福的machine learning 课程,作业任务是用matlab实现梯度下降算法,theta(j)=theta-alpha*(theta(j)'s derivative of costFunction).实现之后,costFunction应该是逐渐收敛.
用matlab实现梯度下降算法(gradient descent).看的斯坦福的machine learning 课程,作业任务是用matlab实现梯度下降算法,theta(j)=theta-alpha*(theta(j)'s derivative of costFunction).实现之后,costFunction应该是逐渐
function [theta, J_history] = gradientDescent(X, y, theta, alpha, num_iters)
%GRADIENTDESCENT Performs gradient descent to learn theta
% theta = GRADIENTDESENT(X, y, theta, alpha, num_iters) updates theta by
% taking num_iters gradient steps with learning rate alpha
% Initialize some useful values
m = length(y); % number of training examples
J_history = zeros(num_iters, 1);
for iter = 1:num_iters,
%
% Save the cost J in every iteration
J_history(iter) = computeCost(X, y, theta);
end
end