- 使用 Spring Initializr 创建 Spring Boot 应用程序
- 在Spring Boot中配置Cassandra
- 在 Spring Boot 上配置 Tomcat 连接池
- 将Camel消息路由到嵌入WildFly的Artemis上
本文整理了Java中edu.illinois.cs.cogcomp.sl.util.WeightVector.dotProduct()
方法的一些代码示例,展示了WeightVector.dotProduct()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WeightVector.dotProduct()
方法的具体详情如下:
包路径:edu.illinois.cs.cogcomp.sl.util.WeightVector
类名称:WeightVector
方法名:dotProduct
暂无
代码示例来源:origin: edu.illinois.cs.cogcomp/illinois-sl-core
/***
* Computes wv^T\phi(x,y).
* Override this function if you have a faster implementation for computing
* wv^T\phi(x,y).
* @param wv
* @param x
* @param y
* @return
*/
public float decisionValue(WeightVector wv, IInstance x, IStructure y) {
return wv.dotProduct(getFeatureVector(x, y));
}
代码示例来源:origin: edu.illinois.cs.cogcomp/illinois-sl
/***
* Computes wv^T\phi(x,y).
* Override this function if you have a faster implementation for computing
* wv^T\phi(x,y).
* @param wv
* @param x
* @param y
* @return
*/
public float decisionValue(WeightVector wv, IInstance x, IStructure y) {
return wv.dotProduct(getFeatureVector(x, y));
}
代码示例来源:origin: edu.illinois.cs.cogcomp/illinois-sl
@Override
public IStructure getBestStructure(WeightVector weight, IInstance ins)
throws Exception {
RankingInstance ri = (RankingInstance) ins;
int maxIndex = -1;
double maxScore = Double.NEGATIVE_INFINITY;
for(int i=0; i < ri.featureList.size(); i ++){
double score = weight.dotProduct(ri.featureList.get(i));
if (score > maxScore){
maxScore = score;
maxIndex = i;
}
}
assert maxIndex != -1;
return new RankingLabel(maxIndex);
}
@Override
代码示例来源:origin: edu.illinois.cs.cogcomp/illinois-sl
@Override
public IStructure getLossAugmentedBestStructure(
WeightVector weight, IInstance ins, IStructure goldStructure)
throws Exception {
RankingInstance ri = (RankingInstance) ins;
RankingLabel lri = (RankingLabel) goldStructure;
int max_index = -1;
double max_score = Double.NEGATIVE_INFINITY;
for(int i=0; i < ri.featureList.size(); i ++){
float loss = -ri.scoreList.get(i)+ ri.scoreList.get(lri.pred_item);
if (loss< 0){
System.out.println("-----------");
System.out.println(ri.scoreList);
System.out.println("best: " + lri.pred_item);
}
assert loss >= 0;
float score = weight.dotProduct(ri.featureList.get(i)) + loss;
if (score > max_score){
max_score = score;
max_index = i;
}
}
assert max_index != -1;
RankingLabel pred = new RankingLabel(max_index);
//System.out.println("pred: " + max_index + " gold: " + lri.pred_item);
return pred;
}
代码示例来源:origin: edu.illinois.cs.cogcomp/illinois-sl
@Override
public IStructure getLossAugmentedBestStructure(
WeightVector weight, IInstance ins, IStructure goldStructure)
throws Exception {
MultiClassInstance mi = (MultiClassInstance) ins;
MultiClassLabel lmi = (MultiClassLabel) goldStructure;
int bestOutput = -1;
float bestScore = Float.NEGATIVE_INFINITY;
for(int i=0; i < mi.numberOfClasses ; i ++){
float score = weight.dotProduct(mi.baseFv,mi.baseNfeature*i);
if (lmi!=null && i != lmi.output){
if(lossMatrix == null)
score += 1.0;
else
score += lossMatrix[lmi.output][i];
}
if (score > bestScore){
bestOutput = i;
bestScore = score;
}
}
assert bestOutput >= 0 ;
return new MultiClassLabel(bestOutput);
}
代码示例来源:origin: edu.illinois.cs.cogcomp/illinois-depparse
private String predictLabel(int head, int node, DepInst ins, WeightVector weight) {
if (head == -1)
throw new IllegalArgumentException("Invalid arc, head must be positive!");
String rel = null;
float max = Float.NEGATIVE_INFINITY;
String keyPOS = ins.strPos[head] + " " + ins.strPos[node];
Set<String> candidates = new HashSet<>();
if (deprelDict.get(keyPOS) != null)
candidates.addAll(deprelDict.get(keyPOS));
if (candidates.size() == 1)
return candidates.iterator().next();
else if (candidates.isEmpty()) {
if (keyPOS.contains("."))
return "P";
candidates.addAll(ALL_RELS);
}
for (String candidate : candidates) {
FeatureVectorBuffer edgefv = depfeat.getLabeledEdgeFeatures(head, node, ins, candidate);
float decision = weight.dotProduct(edgefv.toFeatureVector(false));
if (decision > max) {
rel = candidate;
max = decision;
}
}
return rel;
}
代码示例来源:origin: CogComp/cogcomp-nlp
private String predictLabel(int head, int node, DepInst ins, WeightVector weight) {
if (head == -1)
throw new IllegalArgumentException("Invalid arc, head must be positive!");
String rel = null;
float max = Float.NEGATIVE_INFINITY;
String keyPOS = ins.strPos[head] + " " + ins.strPos[node];
Set<String> candidates = new HashSet<>();
if (deprelDict.get(keyPOS) != null)
candidates.addAll(deprelDict.get(keyPOS));
if (candidates.size() == 1)
return candidates.iterator().next();
else if (candidates.isEmpty()) {
if (keyPOS.contains("."))
return "P";
candidates.addAll(ALL_RELS);
}
for (String candidate : candidates) {
FeatureVectorBuffer edgefv = depfeat.getLabeledEdgeFeatures(head, node, ins, candidate);
float decision = weight.dotProduct(edgefv.toFeatureVector(false));
if (decision > max) {
rel = candidate;
max = decision;
}
}
return rel;
}
代码示例来源:origin: edu.illinois.cs.cogcomp/IllinoisSL-core
private void printErrorLogForIncorrectInference(WeightVector wv, float loss, IStructure h,
float xi, float dotProduct, float score,
float max_score_in_cache) {
logger.error("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
logger.error("The inference procedure is not correct!");
logger.error("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
logger.error("Pred: " + h);
logger.error("docproduct on pred: "
+ wv.dotProduct(h.getFeatureVector()));
logger.error("dotproduct on diff: " + dotProduct);
logger.error("loss: " + loss);
logger.error("xi: " + xi);
logger.error("Warning: the inference (argmax) code is not right......");
logger.error("score: " + score);
logger.error("max score in cache: " + max_score_in_cache);
for (int i = 0; i < goldStructureList.size(); i++) {
IStructure f = goldStructureList.get(i);
Pair<float[], FeatureVector> pair = alphaFeatureVectorList.get(i);
logger.error(">>>" + f + " alpha: " + pair.getFirst()[0]
+ " loss: " + pair.getFirst()[1]);
logger.error(">>> (dot) "
+ wv.dotProduct(pair.getSecond()));
}
logger.error("[GOLD]" + goldStructure);
logger.error("gold dot product: "
+ wv.dotProduct(goldStructure.getFeatureVector()));
}
代码示例来源:origin: edu.illinois.cs.cogcomp/illinois-sl-core
float dot_product = wv.dotProduct(fv);
float xij_norm2 = fv.getSquareL2Norm();
代码示例来源:origin: edu.illinois.cs.cogcomp/illinois-sl-core
float dotProduct = wv.dotProduct(diff);
float score = (loss - dotProduct) - xi; // line 12 in DCD-SSVM (algorithm 3 in paper)
for(AlphaStruct as:new ArrayList<AlphaStruct>(candidateAlphas)){
if(as !=null){
float s = as.loss - wv.dotProduct(as.alphaFeactureVector) - xi;
if (max_score_in_cache < s)
max_score_in_cache = s;
代码示例来源:origin: edu.illinois.cs.cogcomp/IllinoisSL-core
/**
* Get primal objective function value with respect to the weight vector wv
* @param sp
* @param wv
* @param infSolver
* @param C
* @return
* @throws Exception
*/
public static float getPrimalObjective(
StructuredProblem sp, WeightVector wv,
AbstractInferenceSolver infSolver, float C) throws Exception {
float obj = 0;
obj += wv.getSquareL2Norm() * 0.5;
List<IInstance> input_list = sp.instanceList;
List<IStructure> output_list = sp.goldStructureList;
for (int i = 0; i < input_list.size(); i++) {
IInstance ins = input_list.get(i);
IStructure gold_struct = output_list.get(i);
float sC= C;
Pair<IStructure, Float > res = infSolver
.getLossAugmentedBestStructure(wv, ins, gold_struct);
float loss = res.getSecond()
+ wv.dotProduct(res.getFirst().getFeatureVector())
- wv.dotProduct(gold_struct.getFeatureVector());
obj += sC * loss * loss;
}
return obj;
}
代码示例来源:origin: edu.illinois.cs.cogcomp/illinois-srl
public double getIdentifierRawScore(SRLMulticlassInstance x) throws Exception {
log.debug("Classifying {}", x);
WeightVector w = manager.getModelInfo(Models.Identifier).getWeights();
SRLMulticlassLabel y1 = new SRLMulticlassLabel(1, Models.Identifier, manager);
SRLMulticlassLabel y0 = new SRLMulticlassLabel(0, Models.Identifier, manager);
double score1= w.dotProduct(x.getCachedFeatureVector(Models.Identifier),1 * manager.getModelInfo(Models.Identifier).getLexicon().size());
double score2= w.dotProduct(x.getCachedFeatureVector(Models.Identifier));
return (double) (score1 - score2);
}
代码示例来源:origin: CogComp/cogcomp-nlp
/**
* Scores instance for the different labels allowed for it
*/
public double[] getScores(SenseInstance x, boolean rescoreInvalidLabels) {
int numLabels = this.getNumLabels();
double[] scores = new double[numLabels];
WeightVector w;
try {
w = this.getModelInfo().getWeights();
assert w != null;
} catch (Exception e) {
log.error("Unable to load weight vector, exception:\n{}", e);
throw new RuntimeException(e);
}
for (int label = 0; label < numLabels; label++) {
if (!this.isValidLabel(x, label) && rescoreInvalidLabels) {
scores[label] = -50;
} else {
SenseStructure y = new SenseStructure(x, label, this);
scores[label] = w.dotProduct(y.getFeatureVector());
}
}
scores = MathUtilities.softmax(scores);
return scores;
}
代码示例来源:origin: edu.illinois.cs.cogcomp/illinois-verbsense
/**
* Scores instance for the different labels allowed for it
*/
public double[] getScores(SenseInstance x, boolean rescoreInvalidLabels) {
int numLabels = this.getNumLabels();
double[] scores = new double[numLabels];
WeightVector w;
try {
w = this.getModelInfo().getWeights();
assert w != null;
} catch (Exception e) {
log.error("Unable to load weight vector, exception:\n{}", e);
throw new RuntimeException(e);
}
for (int label = 0; label < numLabels; label++) {
if (!this.isValidLabel(x, label) && rescoreInvalidLabels) {
scores[label] = -50;
} else {
SenseStructure y = new SenseStructure(x, label, this);
scores[label] = w.dotProduct(y.getFeatureVector());
}
}
scores = MathUtilities.softmax(scores);
return scores;
}
代码示例来源:origin: CogComp/cogcomp-nlp
double score = weight.dotProduct(y.getFeatureVector());
代码示例来源:origin: edu.illinois.cs.cogcomp/illinois-verbsense
double score = weight.dotProduct(y.getFeatureVector());
代码示例来源:origin: edu.illinois.cs.cogcomp/illinois-srl
/**
* Scores instance for the different labels allowed for it
*/
public double[] getScores(SRLMulticlassInstance x, Models type, boolean rescoreInvalidLabels) {
int numLabels = this.getNumLabels(type);
double[] scores = new double[numLabels];
WeightVector w;
try {
w = this.getModelInfo(type).getWeights();
assert w != null;
} catch (Exception e) {
log.error("Unable to load weight vector for {}", type, e);
throw new RuntimeException(e);
}
for (int label = 0; label < numLabels; label++) {
if (!this.isValidLabel(x, type, label) && rescoreInvalidLabels) {
scores[label] = -50;
}
else {
scores[label] = w.dotProduct(x.getCachedFeatureVector(type),label * this.getModelInfo(type).getLexicon().size());
}
}
scores = MathUtilities.softmax(scores);
return scores;
}
代码示例来源:origin: edu.illinois.cs.cogcomp/illinois-sl-core
IFeatureVector predictedFeatures = featureGenerator.getFeatureVector(example, prediction);
IFeatureVector update = goldFeatures.difference(predictedFeatures);
double loss_term = loss - w.dotProduct(update);
代码示例来源:origin: CogComp/cogcomp-nlp
@Override
public IStructure getLossAugmentedBestStructure(WeightVector weight, IInstance ins,
IStructure goldStructure) throws Exception {
DepInst sent = (DepInst) ins;
DepStruct gold = goldStructure != null ? (DepStruct) goldStructure : null;
// edgeScore[i][j] score of edge from head i to modifier j
// i (head) varies from 0..n, while j (token idx) varies over 1..n
double[][] edgeScore = new double[sent.size() + 1][sent.size() + 1];
String[][] edgeLabel = new String[sent.size() + 1][sent.size() + 1];
initEdge(edgeScore, edgeLabel);
for (int head = 0; head <= sent.size(); head++) {
for (int j = 1; j <= sent.size(); j++) {
if (head == j) {
edgeScore[head][j] = Double.NEGATIVE_INFINITY;
continue;
}
String deprel = predictLabel(head, j, sent, weight);
edgeLabel[head][j] = deprel;
FeatureVectorBuffer edgefv = depfeat.getCombineEdgeFeatures(head, j, sent, deprel);
// edge from head i to modifier j
edgeScore[head][j] = weight.dotProduct(edgefv.toFeatureVector(false));
if (gold != null) {
if (gold.heads[j] != head || !deprel.equals(gold.deprels[j])) // incur loss
edgeScore[head][j] += 1.0f;
}
}
}
return LabeledChuLiuEdmonds(edgeScore, edgeLabel);
}
代码示例来源:origin: edu.illinois.cs.cogcomp/illinois-depparse
@Override
public IStructure getLossAugmentedBestStructure(WeightVector weight, IInstance ins,
IStructure goldStructure) throws Exception {
DepInst sent = (DepInst) ins;
DepStruct gold = goldStructure != null ? (DepStruct) goldStructure : null;
// edgeScore[i][j] score of edge from head i to modifier j
// i (head) varies from 0..n, while j (token idx) varies over 1..n
double[][] edgeScore = new double[sent.size() + 1][sent.size() + 1];
String[][] edgeLabel = new String[sent.size() + 1][sent.size() + 1];
initEdge(edgeScore, edgeLabel);
for (int head = 0; head <= sent.size(); head++) {
for (int j = 1; j <= sent.size(); j++) {
if (head == j) {
edgeScore[head][j] = Double.NEGATIVE_INFINITY;
continue;
}
String deprel = predictLabel(head, j, sent, weight);
edgeLabel[head][j] = deprel;
FeatureVectorBuffer edgefv = depfeat.getCombineEdgeFeatures(head, j, sent, deprel);
// edge from head i to modifier j
edgeScore[head][j] = weight.dotProduct(edgefv.toFeatureVector(false));
if (gold != null) {
if (gold.heads[j] != head || !deprel.equals(gold.deprels[j])) // incur loss
edgeScore[head][j] += 1.0f;
}
}
}
return LabeledChuLiuEdmonds(edgeScore, edgeLabel);
}
我在这个网站上发布的代码有这个问题 https://developers.google.com/drive/quickstart-cs是 Google Drive 快速入门的开发人员站点。我按照网站上
我正在尝试制作一个非常简单的 Kafka Producer,目前正在关注 producer example除了我的制作人没有分区程序类。 将所需文件导出到 jar 后,我将它们传输到我的 Linux
问题 在java中,我有一个“Util项目”,在进行单元测试时使用另一个“Mock项目”。 我的问题是“模拟项目”也使用“Util项目”来构建一些模拟对象。 当我使用 Maven 构建项目时,我无法构
据我所知,这些包已经存在很长时间了。但是,我从未见过它们的实际用法。而且这些包似乎不成熟,不再维护。如果是,为什么这些包现在存在? 最佳答案 包裹automata被 scala.xml.dtd 使用,
关闭。这个问题需要debugging details .它目前不接受答案。 想改进这个问题?将问题更新为 on-topic对于堆栈溢出。 1年前关闭。 Improve this question Co
在java.util.Collections中,有一个方法: public static void fill(List list, T obj) 用第二个参数指定的对象填充第一个参数指定的List。
我不明白它要我做什么。分配给 sentence正在工作: val sentences : java.util.List[CoreMap] = document.get(classOf[Sentence
在我的 React 应用程序中,我想使用一些实用程序。我见过两种不同的方法。第一个是,只是创建函数并将其导出。第二个是,创建一个 Util 类并导出一个对象,这样它就不能被实例化(静态类)。 clas
我有一个 util 类,它接受 String jwtToken 和 Key key 并使用 io.jsonwebtoken.jwts 解码 jwt。 但是,我无法对此进行测试。原因是,我无法模拟公钥并
我有使用目标命名空间的专有架构 xmlns:ax216="http://util.java/xsd" 这给我带来了从 java (java.util.xsd) 开始生成禁止的(由 Java 安全管理器
我正在阅读集合以查看 Javadocs 中的实现层次结构。 Collections声明为public class Collections extendds Object Collection声明为pu
我正在使用 Spring-boot 应用程序,我可以在其中连接 Azure 应用程序配置。但是当我尝试使用内容类型应用程序/JSON 读取值时出现错误。 我的Java类 @ConfigurationP
我正在使用 Spring-boot 应用程序,我可以在其中连接 Azure 应用程序配置。但是当我尝试使用内容类型应用程序/JSON 读取值时出现错误。 我的Java类 @ConfigurationP
我在使用格式说明符时遇到问题。这是否意味着我正在使用 %d? public static void main(String[] args) { double y, x; for (x =
鉴于此代码 import java.util.Iterator; private static List someList = new ArrayList(); public static void
我正在 HackerEarth 解决问题,我无法弄清楚为什么我的程序在命令行上正确运行并给出正确的结果,但在代码编辑器上运行时却给出 java.util.NoSuchElementException
我正在尝试使用以下代码使用对象列表列表中的数据填充tableModel readExcel.readSheet(0): TableModel tableModel = new DefaultTabl
java.util.Set 、 java.util.List 和其他 Collection 接口(interface)不可序列化。需要一个简单、直接的解决方案来在可序列化的 POJO 中使用它。 pu
我试图从 servlet 返回数据库搜索结果的 ArrayList 以显示在 jsp 页面上。 在servlet中设置arraylist作为请求的属性,并将请求转发到jsp页面。当我尝试在 jsp 页
我是android新手,最近我试图从firebase中提取数据到recyclerview/cardview中以垂直布局显示数据,它显示将Hashmap转换为Arraylist的错误,其中代码是:
我是一名优秀的程序员,十分优秀!