0
使用梯度的矢量化版本在描述: gradient descent seems to fail梯度下降不更新2θ值
theta = theta - (alpha/m * (X * theta-y)' * X)';
的2θ值不被更新,所以無論初始THETA值 這是後設置的值運行梯度下降:
例1:
m = 1
X = [1]
y = [0]
theta = 2
theta = theta - (alpha/m .* (X .* theta-y)' * X)'
theta =
2.0000
例2:
m = 1
X = [1;1;1]
y = [1;0;1]
theta = [1;2;3]
theta = theta - (alpha/m .* (X .* theta-y)' * X)'
theta =
1.0000
2.0000
3.0000
是theta = theta - (alpha/m * (X * theta-y)' * X)';
梯度下降的正確向量化實現?