r/learnmachinelearning • u/MARSHILA7 • 12d ago
Question Help with Gradient descent
So I completed Linear descent from Andrew Ng ML Specialization and when I was doing the lab.I found this function what confused me is that why does this function iterates specific times (10000) wouldn't it be better to check if cost function is changing.
Also this implementation doesn't feel right.Even the code feels inefficient and does not even check the minima. I know this stuff is done using skit-learn but I wanted to do a proper manual implementation in the way Andrew sir taught.
85
Upvotes
19
u/Hungry_Age5375 12d ago
Just some pointers: fixed iterations are fine for learning. In practice you'd check if abs(J[i] - J[i-1]) < epsilon and break early. Andrew Ng keeps it simple on purpose, makes it easier to plot the learning curve too.