ex1的提交,只贴添加内容

warmUpExercise.m

A = eye(5);

 

computeCost.m

J = sum((X*theta-y).^2);
J = J/(2*m);

 

gradientDescent.m

theta = theta - alpha*X'*(X*theta - y)/m;

 

featureNormalize.m

for i = 1:size(X,2)
    mu(1,i) = mean(X(:,i));
end

for i = 1:size(X,2)
    sigma(1, i) = std(X(:,i));
end
for i = 1:size(X,1)
    for j = 1:size(X,2)
        X_norm(i,j) = (X(i,j)-mu(1,j))/sigma(1,j);
    end

 

computeCostMulti.m

J = (X*theta-y)'*(X*theta-y)/(2*m);

 

gradientDescentMulti.m

theta = theta - alpha*X'*(X*theta - y)/m;

 

normalEqn.m

theta = (pinv(X*X')*X)'*y

 

相关文章:

  • 2021-11-23
  • 2021-09-02
  • 2021-07-26
  • 2021-12-09
  • 2021-09-16
  • 2021-09-19
  • 2021-05-03
  • 2021-11-15
猜你喜欢
  • 2022-12-23
  • 2021-04-02
  • 2021-04-16
  • 2021-04-09
  • 2021-05-08
  • 2021-07-30
  • 2022-02-24
相关资源
相似解决方案