gpt4 book ai didi

edu.illinois.cs.cogcomp.sl.util.WeightVector.getSquareL2Norm()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-25 05:37:05 26 4
gpt4 key购买 nike

本文整理了Java中edu.illinois.cs.cogcomp.sl.util.WeightVector.getSquareL2Norm()方法的一些代码示例,展示了WeightVector.getSquareL2Norm()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WeightVector.getSquareL2Norm()方法的具体详情如下:
包路径:edu.illinois.cs.cogcomp.sl.util.WeightVector
类名称:WeightVector
方法名:getSquareL2Norm

WeightVector.getSquareL2Norm介绍

暂无

代码示例

代码示例来源:origin: edu.illinois.cs.cogcomp/illinois-sl-core

protected static float getDualObjective(
    StructuredInstanceWithAlphas[] alphaInsList, WeightVector wv) {
  float obj = 0;
  obj += wv.getSquareL2Norm() * 0.5;
  for (int i = 0; i < alphaInsList.length; i++) {
    StructuredInstanceWithAlphas instanceWithAlphas = alphaInsList[i];
    float w_sum = instanceWithAlphas.getLossWeightAlphaSum();
    float sum = instanceWithAlphas.alphaSum;
    float C = instanceWithAlphas.getC();
    obj -= w_sum;
    obj += (1.0 / (4.0 * C)) * sum * sum;
  }
  return obj;
}

代码示例来源:origin: edu.illinois.cs.cogcomp/illinois-sl

protected static float getDualObjective(
    StructuredInstanceWithAlphas[] alphaInsList, WeightVector wv) {
  float obj = 0;
  obj += wv.getSquareL2Norm() * 0.5;
  for (int i = 0; i < alphaInsList.length; i++) {
    StructuredInstanceWithAlphas instanceWithAlphas = alphaInsList[i];
    float w_sum = instanceWithAlphas.getLossWeightAlphaSum();
    float sum = instanceWithAlphas.alphaSum;
    float C = instanceWithAlphas.getC();
    obj -= w_sum;
    obj += (1.0 / (4.0 * C)) * sum * sum;
  }
  return obj;
}

代码示例来源:origin: edu.illinois.cs.cogcomp/IllinoisSL-core

protected static float getDualObjective(
    StructuredInstanceWithAlphas[] alphaInsList, WeightVector wv) {
  float obj = 0;
  obj += wv.getSquareL2Norm() * 0.5;
  for (int i = 0; i < alphaInsList.length; i++) {
    StructuredInstanceWithAlphas instanceWithAlphas = alphaInsList[i];
    float w_sum = instanceWithAlphas.getLossWeightAlphaSum();
    float sum = instanceWithAlphas.getAlphaSum();
    float C = instanceWithAlphas.getC();
    obj -= w_sum;
    obj += (1.0 / (4.0 * C)) * sum * sum;
  }
  return obj;
}

代码示例来源:origin: edu.illinois.cs.cogcomp/illinois-sl-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 float getPrimalObjective(
    SLProblem 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;
    IStructure h = infSolver
        .getLossAugmentedBestStructure(wv, ins, gold_struct);
    float loss = infSolver.getLoss(ins, gold_struct, h)
        + this.featureGenerator.decisionValue(wv, ins, h)
        - this.featureGenerator.decisionValue(wv, ins, gold_struct);
    obj += sC * loss ;
  }
  return obj;
}

代码示例来源:origin: edu.illinois.cs.cogcomp/illinois-sl

/**
 * Get primal objective function value with respect to the weight vector wv
 * @param sp
 * @param wv
 * @param infSolver
 * @param C
 * @return
 * @throws Exception
 */
public float getPrimalObjective(
    SLProblem 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;
    IStructure h = infSolver
        .getLossAugmentedBestStructure(wv, ins, gold_struct);
    float loss = infSolver.getLoss(ins, gold_struct, h)
        + this.featureGenerator.decisionValue(wv, ins, h)
        - this.featureGenerator.decisionValue(wv, ins, gold_struct);
    obj += sC * loss * loss;
  }
  return obj;
}

代码示例来源:origin: edu.illinois.cs.cogcomp/illinois-sl-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 float getPrimalObjective(
    SLProblem 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;
    IStructure h = infSolver
        .getLossAugmentedBestStructure(wv, ins, gold_struct);
    float loss = infSolver.getLoss(ins, gold_struct, h)
        + this.featureGenerator.decisionValue(wv, ins, h)
        - this.featureGenerator.decisionValue(wv, ins, gold_struct);
    obj += sC * loss * loss;
  }
  return obj;
}

代码示例来源: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;
}

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com