resetExpectations();
/* Fill in expectations for each instance */
for (int i = 0; i < numInstances; i++)
{
Instance instance = trainData.get(i);
/* Compute marginals for each clique */
long unrollStart = System.currentTimeMillis ();
ACRF.UnrolledGraph unrolled = new ACRF.UnrolledGraph (instance, templates, fixedTmpls);
long unrollEnd = System.currentTimeMillis ();
unrollTime += (unrollEnd - unrollStart);
if (unrolled.numVariables () == 0) continue; // Happens if all nodes are pruned.
/* Save the expected value of each feature for when we
compute the gradient. */
Assignment observations = unrolled.getAssignment ();
double value = collectExpectationsAndValue (unrolled, observations);
if (Double.isInfinite(value))
{
if (initializingInfiniteValues) {
logger.warning ("Instance " + instance.getName() +
" has infinite value; skipping.");
infiniteValues.set (i);
continue;
} else if (!infiniteValues.get(i)) {
logger.warning ("Infinite value on instance "+instance.getName()+
"returning -infinity");
return Double.NEGATIVE_INFINITY;
/*
printDebugInfo (unrolled);
throw new IllegalStateException
("Instance " + instance.getName()+ " used to have non-infinite"
+ " value, but now it has infinite value.");
*/
}
} else if (Double.isNaN (value)) {
System.out.println("NaN on instance "+i+" : "+instance.getName ());
printDebugInfo (unrolled);
/* throw new IllegalStateException
("Value is NaN in ACRF.getValue() Instance "+i);
*/
logger.warning ("Value is NaN in ACRF.getValue() Instance "+i+" : "+