为什么梯度下降时我们可以解析线性回归 [英] why gradient descent when we can solve linear regression analytically

查看:89
本文介绍了为什么梯度下降时我们可以解析线性回归的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在线性回归空间中使用梯度下降有什么好处?看起来我们可以用分析方法解决问题(找到最小的成本函数的theta0-n),那么为什么我们仍然要使用梯度下降来做同样的事情?谢谢

what is the benefit of using Gradient Descent in the linear regression space? looks like the we can solve the problem (finding theta0-n that minimum the cost func) with analytical method so why we still want to use gradient descent to do the same thing? thanks

推荐答案

使用正态方程来分析成本函数时,您必须计算:

When you use the normal equations for solving the cost function analytically you have to compute:

其中X是您的输入观察矩阵,y是您的输出向量.此操作的问题是计算n(n ^ 3)的nxn矩阵的逆的时间复杂度,并且随着n的增加,它可能需要很长时间才能完成.

Where X is your matrix of input observations and y your output vector. The problem with this operation is the time complexity of calculating the inverse of a nxn matrix which is O(n^3) and as n increases it can take a very long time to finish.

当n较低(n <1000或n <10000)时,您可以将正则方程视为计算theta的更好选择,但是对于更大的值,梯度下降要快得多,所以唯一的原因是时间:)

When n is low (n < 1000 or n < 10000) you can think of normal equations as the better option for calculation theta, however for greater values Gradient Descent is much more faster, so the only reason is the time :)

这篇关于为什么梯度下降时我们可以解析线性回归的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆