@Override public void addConstraint(int fi, double[] ex, double weight) { constraints.put(fi,new MaxEntL2FLGEConstraint(ex,weight)); }
public void addConstraint(int fi, int li, double lower, double upper, double weight) { if (!constraints.containsKey(fi)) { constraints.put(fi,new MaxEntL2IndGEConstraint()); } constraints.get(fi).add(li, lower, upper, weight); }
public double getValue() { double value = 0.0; for (int fi : constraints.keys()) { MaxEntL2IndGEConstraint constraint = constraints.get(fi); if ( constraint.count > 0.0) { // value due to current constraint for (int labelIndex = 0; labelIndex < numLabels; ++labelIndex) { value -= constraint.getValue(labelIndex); } } } assert(!Double.isNaN(value) && !Double.isInfinite(value)); return value; }
public void zeroExpectations() { for (int fi : constraints.keys()) { constraints.get(fi).expectation = new double[constraints.get(fi).getNumConstrainedLabels()]; } }
public double getCompositeConstraintFeatureValue(FeatureVector input, int label) { double value = 0; for (int i = 0; i < indexCache.size(); i++) { if (useValues) { value += constraints.get(indexCache.getQuick(i)).getGradientContribution(label) * valueCache.getQuick(i); } else { value += constraints.get(indexCache.getQuick(i)).getGradientContribution(label); } } return value; }
public double getCompositeConstraintFeatureValue(FeatureVector input, int label) { double value = 0; for (int i = 0; i < indexCache.size(); i++) { if (useValues) { value += constraints.get(indexCache.getQuick(i)).getValue(label) * valueCache.getQuick(i); } else { value += constraints.get(indexCache.getQuick(i)).getValue(label); } } return value; }
@Override public void addConstraint(int fi, double[] ex, double weight) { assert(Maths.almostEquals(MatrixOps.sum(ex),1)); constraints.put(fi,new MaxEntKLFLGEConstraint(ex,weight)); }
public void addConstraint(int fi, int li, double lower, double upper, double weight) { if (!constraints.containsKey(fi)) { constraints.put(fi,new MaxEntL2IndGEConstraint()); } constraints.get(fi).add(li, lower, upper, weight); }
public void zeroExpectations() { for (int fi : constraints.keys()) { constraints.get(fi).expectation = new double[constraints.get(fi).getNumConstrainedLabels()]; } }
@Override public void addConstraint(int fi, double[] ex, double weight) { constraints.put(fi,new MaxEntL2FLGEConstraint(ex,weight)); }
public double getValue() { double value = 0.0; for (int fi : constraints.keys()) { MaxEntL2IndGEConstraint constraint = constraints.get(fi); if ( constraint.count > 0.0) { // value due to current constraint for (int labelIndex = 0; labelIndex < numLabels; ++labelIndex) { value -= constraint.getValue(labelIndex); } } } assert(!Double.isNaN(value) && !Double.isInfinite(value)); return value; }
public double getCompositeConstraintFeatureValue(FeatureVector input, int label) { double value = 0; for (int i = 0; i < indexCache.size(); i++) { if (useValues) { value += constraints.get(indexCache.getQuick(i)).getGradientContribution(label) * valueCache.getQuick(i); } else { value += constraints.get(indexCache.getQuick(i)).getGradientContribution(label); } } return value; }
public double getCompositeConstraintFeatureValue(FeatureVector input, int label) { double value = 0; for (int i = 0; i < indexCache.size(); i++) { if (useValues) { value += constraints.get(indexCache.getQuick(i)).getValue(label) * valueCache.getQuick(i); } else { value += constraints.get(indexCache.getQuick(i)).getValue(label); } } return value; }
@Override public void addConstraint(int fi, double[] ex, double weight) { assert(Maths.almostEquals(MatrixOps.sum(ex),1)); constraints.put(fi,new MaxEntKLFLGEConstraint(ex,weight)); }
public void addConstraint(int fi, int li, double lower, double upper, double weight) { if (!constraints.containsKey(fi)) { constraints.put(fi,new MaxEntL2IndGEConstraint()); } constraints.get(fi).add(li, lower, upper, weight); }
public void zeroExpectations() { for (int fi : constraints.keys()) { constraints.get(fi).expectation = new double[constraints.get(fi).getNumConstrainedLabels()]; } }
@Override public void addConstraint(int fi, double[] ex, double weight) { constraints.put(fi,new MaxEntL2FLGEConstraint(ex,weight)); }
public double getValue() { double value = 0.0; for (int fi : constraints.keys()) { MaxEntL2IndGEConstraint constraint = constraints.get(fi); if ( constraint.count > 0.0) { // value due to current constraint for (int labelIndex = 0; labelIndex < numLabels; ++labelIndex) { value -= constraint.getValue(labelIndex); } } } assert(!Double.isNaN(value) && !Double.isInfinite(value)); return value; }
public double getCompositeConstraintFeatureValue(FeatureVector input, int label) { double value = 0; for (int i = 0; i < indexCache.size(); i++) { if (useValues) { value += constraints.get(indexCache.getQuick(i)).getGradientContribution(label) * valueCache.getQuick(i); } else { value += constraints.get(indexCache.getQuick(i)).getGradientContribution(label); } } return value; }
public double getCompositeConstraintFeatureValue(FeatureVector input, int label) { double value = 0; for (int i = 0; i < indexCache.size(); i++) { if (useValues) { value += constraints.get(indexCache.getQuick(i)).getValue(label) * valueCache.getQuick(i); } else { value += constraints.get(indexCache.getQuick(i)).getValue(label); } } return value; }