InstanceList testSet,
ACRFEvaluator eval,
int numIter,
Optimizable.ByGradientValue macrf)
{
Optimizer maximizer = createMaxer (macrf);
// Maximizer.ByGradient maximizer = new BoldDriver ();
// Maximizer.ByGradient maximizer = new GradientDescent ();
boolean converged = false;
boolean resetOnError = true;
long stime = System.currentTimeMillis ();
int numNodes = (macrf instanceof ACRF.MaximizableACRF) ? ((ACRF.MaximizableACRF) macrf).getTotalNodes () : 0;
double thresh = 1e-5 * numNodes; // "early" stopping (reasonably conservative)
if (testSet == null) {
logger.warning ("ACRF trainer: No test set provided.");
}
double prevValue = Double.NEGATIVE_INFINITY;
double currentValue;
int iter;
for (iter = 0; iter < numIter; iter++) {
long etime = new java.util.Date ().getTime ();
logger.info ("ACRF trainer iteration " + iter + " at time " + (etime - stime));
try {
converged = maximizer.optimize (1);
converged |= callEvaluator (acrf, trainingList, validationList, testSet, iter, eval);
if (converged) break;
resetOnError = true;