src/edu/stanford/nlp/sempre/Learner.java
public void learn(int numIters, Map<String, List<Evaluation>> evaluations) {
    LogInfo.begin_track("Learner.learn()");
    // if when we start we have parameters already - need to sort the semantic functions.
    if (!params.isEmpty())
      sortOnFeedback();
    // For each iteration, go through the groups and parse (updating if train).
    for (int iter = 0; iter <= numIters; iter++) {

      LogInfo.begin_track("Iteration %s/%s", iter, numIters);
      Execution.putOutput("iter", iter);

      // Averaged over all iterations
      // Group -> evaluation for that group.
      Map<String, Evaluation> meanEvaluations = Maps.newHashMap();

      // Clear
      for (String group : dataset.groups())
        meanEvaluations.put(group, new Evaluation());

      // Test and train
      for (String group : dataset.groups()) {
        boolean lastIter = (iter == numIters);
        boolean updateWeights = opts.updateWeights && group.equals("train") && !lastIter;  // Don't train on last iteration
        if (opts.skipUnnecessaryGroups) {
          if ((group.equals("train") && lastIter) || (!group.equals("train") && !lastIter))
            continue;
        }
        // Allow the parser to change behavior based on current group and iteration
        parser.onBeginDataGroup(iter, numIters, group);
        Evaluation eval = processExamples(iter, group, dataset.examples(group), updateWeights);
        MapUtils.addToList(evaluations, group, eval);
        meanEvaluations.get(group).add(eval);
        StopWatchSet.logStats();
        writeParams(iter);
      }
      LogInfo.end_track();
    }
    LogInfo.end_track();
  }
/**
   * @param evaluations Evaluations per iteration per group.
   */
@param evaluations Evaluations per iteration per group.
@param evaluations Evaluations per iteration per group .
public void learn(int numIters, Map<String, List<Evaluation>> evaluations) {
    LogInfo.begin_track("Learner.learn()");
    if (!params.isEmpty())
      sortOnFeedback();
    for (int iter = 0; iter <= numIters; iter++) {
      LogInfo.begin_track("Iteration %s/%s", iter, numIters);
      Execution.putOutput("iter", iter);
      Map<String, Evaluation> meanEvaluations = Maps.newHashMap();
      for (String group : dataset.groups())
        meanEvaluations.put(group, new Evaluation());
      for (String group : dataset.groups()) {
        boolean lastIter = (iter == numIters);
        boolean updateWeights = opts.updateWeights && group.equals("train") && !lastIter;  
        if (opts.skipUnnecessaryGroups) {
          if ((group.equals("train") && lastIter) || (!group.equals("train") && !lastIter))
            continue;
        }
        parser.onBeginDataGroup(iter, numIters, group);
        Evaluation eval = processExamples(iter, group, dataset.examples(group), updateWeights);
        MapUtils.addToList(evaluations, group, eval);
        meanEvaluations.get(group).add(eval);
        StopWatchSet.logStats();
        writeParams(iter);
      }
      LogInfo.end_track();
    }
    LogInfo.end_track();
  }
public void learn ( int numIters , Map < String , List < Evaluation > > evaluations ) { LogInfo . begin_track ( "Learner.learn()" ) ; if ( ! params . isEmpty ( ) ) sortOnFeedback ( ) ; for ( int iter = 0 ; iter <= numIters ; iter ++ ) { LogInfo . begin_track ( "Iteration %s/%s" , iter , numIters ) ; Execution . putOutput ( "iter" , iter ) ; Map < String , Evaluation > meanEvaluations = Maps . newHashMap ( ) ; for ( String group : dataset . groups ( ) ) meanEvaluations . put ( group , new Evaluation ( ) ) ; for ( String group : dataset . groups ( ) ) { boolean lastIter = ( iter == numIters ) ; boolean updateWeights = opts . updateWeights && group . equals ( "train" ) && ! lastIter ; if ( opts . skipUnnecessaryGroups ) { if ( ( group . equals ( "train" ) && lastIter ) || ( ! group . equals ( "train" ) && ! lastIter ) ) continue ; } parser . onBeginDataGroup ( iter , numIters , group ) ; Evaluation eval = processExamples ( iter , group , dataset . examples ( group ) , updateWeights ) ; MapUtils . addToList ( evaluations , group , eval ) ; meanEvaluations . get ( group ) . add ( eval ) ; StopWatchSet . logStats ( ) ; writeParams ( iter ) ; } LogInfo . end_track ( ) ; } LogInfo . end_track ( ) ; }
@param evaluations Evaluations per iteration per group.
@param evaluations Evaluations per iteration per group .
// if when we start we have parameters already - need to sort the semantic functions. // For each iteration, go through the groups and parse (updating if train). // Averaged over all iterations // Group -> evaluation for that group. // Clear // Test and train // Don't train on last iteration // Allow the parser to change behavior based on current group and iteration