当前位置: 首页>>代码示例>>Java>>正文


Java SloppyMath.isVeryDangerous方法代码示例

本文整理汇总了Java中edu.berkeley.nlp.math.SloppyMath.isVeryDangerous方法的典型用法代码示例。如果您正苦于以下问题:Java SloppyMath.isVeryDangerous方法的具体用法?Java SloppyMath.isVeryDangerous怎么用?Java SloppyMath.isVeryDangerous使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在edu.berkeley.nlp.math.SloppyMath的用法示例。


在下文中一共展示了SloppyMath.isVeryDangerous方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: delinearizeLexicon

import edu.berkeley.nlp.math.SloppyMath; //导入方法依赖的package包/类
@Override
public void delinearizeLexicon(double[] logProbs) {
	int nDangerous = 0;
	for (short tag = 0; tag < lexicon.hierarchicalScores.length; tag++) {
		for (int word = 0; word < lexicon.hierarchicalScores[tag].length; word++) {
			int index = linearIndex[tag][word];
			double[] vals = lexicon.getLastLevel(tag, word);
			for (int substate = 0; substate < vals.length; substate++) {
				double val = logProbs[index++];
				if (SloppyMath.isVeryDangerous(val)) {
					nDangerous++;
					continue;
				}
				vals[substate] = val;
			}
		}
	}
	if (nDangerous > 0)
		System.out
				.println("Left "
						+ nDangerous
						+ " lexicon weights unchanged since the proposed weight was dangerous.");
	lexicon.explicitlyComputeScores(finalLevel);
	// System.out.println(lexicon);
	// return lexicon;
}
 
开发者ID:text-machine-lab,项目名称:CliRel,代码行数:27,代码来源:HierarchicalLinearizer.java

示例2: sanityCheckLLs

import edu.berkeley.nlp.math.SloppyMath; //导入方法依赖的package包/类
/**
 * @param goldLL
 * @param allLL
 * @param stateSetTree
 * @return
 */
protected boolean sanityCheckLLs(double goldLL, double allLL,
		Tree<StateSet> stateSetTree) {
	if (SloppyMath.isVeryDangerous(allLL)
			|| SloppyMath.isVeryDangerous(goldLL)) {
		unparsableTrees++;
		return false;
	}

	if (goldLL - allLL > 1.0e-4) {
		System.out.println("Something is wrong! The gold LL is "
				+ goldLL + " and the all LL is " + allLL);// +"\n"+sentence+"\n"+stateSetTree);
		System.out.println(stateSetTree);
		incorrectLLTrees++;
		return false;
	}
	return true;
}
 
开发者ID:text-machine-lab,项目名称:CliRel,代码行数:24,代码来源:ParsingObjectiveFunction.java

示例3: l2_regularize

import edu.berkeley.nlp.math.SloppyMath; //导入方法依赖的package包/类
public double l2_regularize(double objective, double[] derivatives) {
	// Incorporate penalty terms (regularization) into the objective and
	// derivatives
	if (SloppyMath.isVeryDangerous(objective))
		return objective;
	double sigma2 = sigma * sigma;
	double penalty = 0.0;
	for (int index = 0; index < x.length; index++) {
		// if (lastX[index]==10000 || Double.isInfinite(lastX[index]))
		// continue;
		penalty += x[index] * x[index];
	}
	// System.out.print(" penalty="+penalty);
	objective -= penalty / (2 * sigma2);

	for (int index = 0; index < x.length; index++) {
		// 'x' and 'derivatives' have same layout
		// if (lastX[index]==10000 || Double.isInfinite(lastX[index]))
		// continue;
		derivatives[index] -= x[index] / sigma2;
		if (SloppyMath.isVeryDangerous(derivatives[index])) {
			System.out
					.println("Setting regularized derivative to zero because it is Inf.");
			derivatives[index] = 0;
		}
	}
	return objective;

}
 
开发者ID:text-machine-lab,项目名称:CliRel,代码行数:30,代码来源:ParsingObjectiveFunction.java

示例4: delinearizeLexicon

import edu.berkeley.nlp.math.SloppyMath; //导入方法依赖的package包/类
public void delinearizeLexicon(double[] logProbs) {
	int nDangerous = 0;
	for (short tag = 0; tag < lexicon.scores.length; tag++) {
		for (int word = 0; word < lexicon.scores[tag][0].length; word++) {
			int index = linearIndex[tag][word];
			for (int substate = 0; substate < lexicon.numSubStates[tag]; substate++) {
				double val = Math.exp(logProbs[index++]);
				if (SloppyMath.isVeryDangerous(val)) {
					System.out
							.println("dangerous value when delinearizng lexicon "
									+ lexicon.scores[tag][substate][word]);
					System.out.println("Word "
							+ lexicon.wordIndexer
									.get(lexicon.tagWordIndexer[tag]
											.get(word)) + " tag "
							+ logProbs[index - 1]);
					val = 0;
					nDangerous++;
					// continue;
				}
				lexicon.scores[tag][substate][word] = val;
			}
		}
	}
	if (nDangerous > 0)
		System.out
				.println("Left "
						+ nDangerous
						+ " lexicon weights unchanged since the proposed weight was dangerous.");
	// return lexicon;
}
 
开发者ID:text-machine-lab,项目名称:CliRel,代码行数:32,代码来源:DefaultLinearizer.java


注:本文中的edu.berkeley.nlp.math.SloppyMath.isVeryDangerous方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。