Vectorization of a gradient descent code

后端 未结 2 399
庸人自扰
庸人自扰 2020-12-25 08:47

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

相关标签:
2条回答
  • 2020-12-25 09:00

    In addition to the answer given by Mad Physicist, the following can also be applied.

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

    0 讨论(0)
  • 2020-12-25 09:02

    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));
    
    0 讨论(0)
提交回复
热议问题