c*a
4 楼
sqrt用binary search啊
超级简单
超级简单
l*s
6 楼
牛顿迭代在machine learning里面貌似很有用
好多模型,比如最大熵,CRF,SVM,等的training方法都是基于这个的,叫L-BFGS。
好多模型,比如最大熵,CRF,SVM,等的training方法都是基于这个的,叫L-BFGS。
s*l
12 楼
:发信人: dreamstring (ric_li), 信区: JobHunting
:标 题: Re: 不会newton多项式
:发信站: BBS 未名空间站 (Tue Jan 22 10:27:34 2013, 美东)
:【 在 lingandcs (lingandcs) 的大作中提到: 】
:: 牛顿迭代在machine learning里面貌似很有用
:: 好多模型,比如最大熵,CRF,SVM,等的training方法都是基于这个的,叫L-BFGS。
BFGS (L-BFGS) 不是严格意义上的牛顿法,而属于拟牛顿法(Quasi-Newton Method).
http://en.wikipedia.org/wiki/BFGS_method
http://en.wikipedia.org/wiki/L-BFGS
http://en.wikipedia.org/wiki/Quasi-Newton_method
:其实能不用尽量都不用,算逆矩阵太费事~~
Quasi-Newton 方法不用算二阶导 (Hessian Matrix) 以及逆矩阵 (inverse of
Hessian),
而是通过一阶导 (gradient vector)来做近似计算 (approximation)。
http://en.wikipedia.org/wiki/Quasi-Newton_method
One of the chief advantages of quasi-Newton methods over Newton's method is
that the Hessian matrix H (or B, in the case of quasi-Newton methods, its
approximation) does not need to be inverted. Newton's method, and its
derivatives such as interior point methods, require the Hessian to be
inverted, which is typically implemented by solving a system of linear
equations and is often quite costly. In contrast, quasi-Newton methods
usually generate an estimate of inv(B) directly.
...
Implementations
Owing to their success, there are implementations of quasi-Newton methods in
almost all programming languages. The NAG Library contains several routines
[1] for minimizing or maximizing a function[2] which use quasi-Newton
algorithms.
In MATLAB's Optimization toolbox, the fminunc function uses (among other
methods) the BFGS Quasi-Newton method. Many of the constrained methods of
the Optimization toolbox use BFGS and the variant L-BFGS. Many user-
contributed quasi-Newton routines are available on MATLAB's file exchange.
Mathematica includes quasi-Newton solvers. R's optim general-purpose
optimizer routine uses the BFGS method by using method="BFGS"[1].
In the SciPy extension to Python, the scipy.optimize.minimize function
includes, among other methods, a BFGS implementation.
http://www.scipy.org/doc/api_docs/SciPy.optimize.lbfgsb.html
:标 题: Re: 不会newton多项式
:发信站: BBS 未名空间站 (Tue Jan 22 10:27:34 2013, 美东)
:【 在 lingandcs (lingandcs) 的大作中提到: 】
:: 牛顿迭代在machine learning里面貌似很有用
:: 好多模型,比如最大熵,CRF,SVM,等的training方法都是基于这个的,叫L-BFGS。
BFGS (L-BFGS) 不是严格意义上的牛顿法,而属于拟牛顿法(Quasi-Newton Method).
http://en.wikipedia.org/wiki/BFGS_method
http://en.wikipedia.org/wiki/L-BFGS
http://en.wikipedia.org/wiki/Quasi-Newton_method
:其实能不用尽量都不用,算逆矩阵太费事~~
Quasi-Newton 方法不用算二阶导 (Hessian Matrix) 以及逆矩阵 (inverse of
Hessian),
而是通过一阶导 (gradient vector)来做近似计算 (approximation)。
http://en.wikipedia.org/wiki/Quasi-Newton_method
One of the chief advantages of quasi-Newton methods over Newton's method is
that the Hessian matrix H (or B, in the case of quasi-Newton methods, its
approximation) does not need to be inverted. Newton's method, and its
derivatives such as interior point methods, require the Hessian to be
inverted, which is typically implemented by solving a system of linear
equations and is often quite costly. In contrast, quasi-Newton methods
usually generate an estimate of inv(B) directly.
...
Implementations
Owing to their success, there are implementations of quasi-Newton methods in
almost all programming languages. The NAG Library contains several routines
[1] for minimizing or maximizing a function[2] which use quasi-Newton
algorithms.
In MATLAB's Optimization toolbox, the fminunc function uses (among other
methods) the BFGS Quasi-Newton method. Many of the constrained methods of
the Optimization toolbox use BFGS and the variant L-BFGS. Many user-
contributed quasi-Newton routines are available on MATLAB's file exchange.
Mathematica includes quasi-Newton solvers. R's optim general-purpose
optimizer routine uses the BFGS method by using method="BFGS"[1].
In the SciPy extension to Python, the scipy.optimize.minimize function
includes, among other methods, a BFGS implementation.
http://www.scipy.org/doc/api_docs/SciPy.optimize.lbfgsb.html
c*a
13 楼
public static double sqrt(double x){
if(x==1 || x==0) return x;
if(x<0)return -1;
double stopCase = 0.00001;
double left = 0, right = x<1? 1:x;
while(right-left>stopCase){
double mid = left + (right - left)/2;
double midSqr = mid * mid;
if(midSqr ==x)return mid;
else if(midSqr > x) right = mid;
else left = mid;
}
return (left+right)/2.0;
}
这样行不行
算不出来的double就return接近的
【在 c********t 的大作中提到】
: double的呢?
相关阅读
内推Java和Javascript软件工程师美女同事控制不住和我搭讪,哈哈有关leetcode的一个问题Google不懂足球,别丢人现眼 (转载)厉害了,英国王室也入选不了的精子库你会在30岁还背景离乡去工作doordash 和 instacart 哪个前景更好呢亚马逊的员工收入从2015年 (转载)GM 的 CEO 也被印度人占领了,还是个女的 (转载)Re: startup offer求建议也说一说刷题心得 (转载)发一个很熟的哥们目前在百度的待遇FB最近manager面试官变烙印了?毕业几年了,为什么一公开发言就紧张的要死Re: 码工的收入中股票RSU占有40%+ (转载)感觉data scientist很水一个geeksforgeeks上的题,有更优解吗感觉和女同事出差,关系就变了小同事经常办公室破口大骂觉得全世界都欠他的IT产业的繁荣期已过,印度码农陷入失业潮