本文整理汇总了Java中cc.mallet.types.MatrixOps.twoNorm方法的典型用法代码示例。如果您正苦于以下问题:Java MatrixOps.twoNorm方法的具体用法?Java MatrixOps.twoNorm怎么用?Java MatrixOps.twoNorm使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cc.mallet.types.MatrixOps
的用法示例。
在下文中一共展示了MatrixOps.twoNorm方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: optimize
import cc.mallet.types.MatrixOps; //导入方法依赖的package包/类
public boolean optimize (int numIterations)
{
int iterations;
double fret;
double fp = optimizable.getValue ();
double[] xi = new double [optimizable.getNumParameters()];
optimizable.getValueGradient(xi);
for (iterations = 0; iterations < numIterations; iterations++) {
logger.info ("At iteration "+iterations+", cost = "+fp+", scaled = "+maxStep+" step = "+step+", gradient infty-norm = "+MatrixOps.infinityNorm (xi));
// Ensure step not too large
double sum = MatrixOps.twoNorm (xi);
if (sum > stpmax) {
logger.info ("*** Step 2-norm "+sum+" greater than max "+stpmax+" Scaling...");
MatrixOps.timesEquals (xi,stpmax/sum);
}
step = lineMaximizer.optimize (xi, step);
fret = optimizable.getValue ();
if (2.0*Math.abs(fret-fp) <= tolerance*(Math.abs(fret)+Math.abs(fp)+eps)) {
logger.info ("Gradient Ascent: Value difference "+Math.abs(fret-fp)+" below " +
"tolerance; saying converged.");
converged = true;
return true;
}
fp = fret;
optimizable.getValueGradient(xi);
if (eval != null) {
eval.evaluate (optimizable, iterations);
}
}
return false;
}
示例2: checkGradientTerminationCondition
import cc.mallet.types.MatrixOps; //导入方法依赖的package包/类
private boolean checkGradientTerminationCondition() {
return MatrixOps.twoNorm(grad) < gradientTolerance;
}