用matlab实现梯度下降算法(gradient descent).看的斯坦福的machine learning 课程,作业任务是用matlab实现梯度下降算法,theta(j)=theta-alpha*(theta(j)'s derivative of costFunction).实现之后,costFunction应该是逐渐
来源:学生作业帮助网 编辑:作业帮 时间:2024/06/17 23:48:16
![用matlab实现梯度下降算法(gradient descent).看的斯坦福的machine learning 课程,作业任务是用matlab实现梯度下降算法,theta(j)=theta-alpha*(theta(j)'s derivative of costFunction).实现之后,costFunction应该是逐渐](/uploads/image/z/6953150-38-0.jpg?t=%E7%94%A8matlab%E5%AE%9E%E7%8E%B0%E6%A2%AF%E5%BA%A6%E4%B8%8B%E9%99%8D%E7%AE%97%E6%B3%95%EF%BC%88gradient+descent%EF%BC%89.%E7%9C%8B%E7%9A%84%E6%96%AF%E5%9D%A6%E7%A6%8F%E7%9A%84machine+learning+%E8%AF%BE%E7%A8%8B%2C%E4%BD%9C%E4%B8%9A%E4%BB%BB%E5%8A%A1%E6%98%AF%E7%94%A8matlab%E5%AE%9E%E7%8E%B0%E6%A2%AF%E5%BA%A6%E4%B8%8B%E9%99%8D%E7%AE%97%E6%B3%95%2Ctheta%28j%29%3Dtheta-alpha%2A%28theta%28j%29%27s+derivative+of+costFunction%29.%E5%AE%9E%E7%8E%B0%E4%B9%8B%E5%90%8E%2CcostFunction%E5%BA%94%E8%AF%A5%E6%98%AF%E9%80%90%E6%B8%90)
用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