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的呢?
相关阅读
eBay的绿卡政策求转CS建议!leetcode开始了收费模式了。烙印的找工作论坛呢startup CEO rankingVMware 的 performance engineer 是干什么的啊?真诚求教new grad的offer选择问题。请教到底能不能申请OPT到哪里查startup风投的情况呢?interview之后多久follow-up?刷题还是project?Box 2 hour coding exerciseNew Grad 找工作挺难啊版上不是很多愿意付头两个月工资找工作的吗?怎么leetcode收费就受不了了?怎么改List<List<Integer>>的值?发bloomberg面经 [电面,目测已挂,赞人品]求教offer选择问题,以及A家选组的问题下周要去面试的公司说TX的9万年薪,和MD10万年薪选哪个?才知道印度人的H1签证都是5年的。中国人的命好苦 (转载)