I am implementing a batch gradient descent on Matlab. I have a problem with the update step of theta
.
theta
is a vector of two components (two rows
In addition to the answer given by Mad Physicist, the following can also be applied.
theta = theta - (alpha/m) * sum( (X * theta - y).* X )';
Looks like you are trying to do a simple matrix multiplication, the thing MATLAB is supposedly best at.
theta = theta - (alpha/m) * (X' * (X*theta-y));