Problem in Gradient descent

I have manually implemented the Linear regression and the value of error goes to infinite

Hi @Deepanshu_garg,
If your error is increasing, that simply means you have not implemented the gradient descent correctly. Try to find where you have made a mistake. A most possible reason is that you might be calculating gradients wrong. If everything is fine then try to keep learning rate low as 0.0001.
Try some changes. And still, if you can’t figure out. Add your code on https://ide.codingblocks.com and send the link here.

Please have a look at my code

As I can see you have made some errors in your code.

  • You have confused m with n and vice versa most of the times. for e.g while creating thetas you should have thetas equal to no. of features, instead, you have created theta equal to the no. of examples. Sometimes while iterating as well.
  • You were calculating gradient wrongly. Check the gradient Function with the mathematical function.
  • Rest, Some minutes mistakes like declaring m and n inside every function.

I’ve updated the code here: https://ide.codingblocks.com/s/114086
Have a look at it, and see where you were wrong. I suppose this code is mostly self-explanatory. But if you feel you didn’t get any line in my code. Feel free to ask here.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.