Why the transpose of y in the Python but not the matlab version?
DLotts opened this issue · 0 comments
DLotts commented
Matlab/Octave:
J = (1/(2*m)) *sum( (((X*theta)-y).^2))
Python :
s = np.power(( X.dot(theta) - np.transpose([y]) ), 2)
J = (1.0/(2*m)) * s.sum( axis = 0 )
They look equivalent except the python has that np.transpose([y])
Why is it needed?
BTW, My Octave version of this cost function is the same as yours.
This is probably not a bug, but it is confusing. You've done a nice job of doing the Python version. It would be an improvement to at least comment on that. I really wanted to do the assignment in NumPy, but Ng's tutorial on Matlab was so easy to follow that I just did the Octave version. Now I can compare the syntax. A Tabla Rosa!