double instanceWeight = trainingList.getInstanceWeight(inst);
Labeling labeling = inst.getLabeling ();
if (labeling == null)
continue;
//logger.fine ("Instance "+ii+" labeling="+labeling);
FeatureVector fv = (FeatureVector) inst.getData ();
Alphabet fdict = fv.getAlphabet();
assert (fv.getAlphabet() == fd);
// Here is the difference between this code and the single label
// version: rather than only picking out the "best" index,
// loop over all label indices.
assert(labeling.numLocations() == trainingSet.getTargetAlphabet().size());
for (int pos = 0; pos < labeling.numLocations(); pos++){
MatrixOps.rowPlusEquals (constraints, numFeatures,
labeling.indexAtLocation(pos),
fv,
instanceWeight*labeling.valueAtLocation(pos));
}
assert(!Double.isNaN(instanceWeight)) : "instanceWeight is NaN";
boolean hasNaN = false;
for (int i = 0; i < fv.numLocations(); i++) {
if (Double.isNaN(fv.valueAtLocation(i))) {
logger.info("NaN for feature " + fdict.lookupObject(fv.indexAtLocation(i)).toString());
hasNaN = true;
}
}
if (hasNaN)
logger.info("NaN in instance: " + inst.getName());