标签:ict end function pre style err fun 结果 bsp
假设 X= [1 1;1 2;1 3]
y = [1;2;3]
theta = [0;0]
costFunction J :
1 function J = costFunction(X,y,theta) 2 m = size(X,1); 3 predictions = X*theta; 4 Errors = (predictions - y).^2; 5 J = 1/(2*m)*sum(Errors); 6 endfunction
J = costFunction(X,y,theta) :得到结果为 杲湩??J = 2.3333
标签:ict end function pre style err fun 结果 bsp
原文地址:https://www.cnblogs.com/liuxjie/p/12036881.html