// A default network trainer. Since no explicit error manager
// information is set, it assumes sum of squares error under the default
// name. The Stop on error listener assumes the default name for sum
// of squares.
public static void main(String[] args) {
  ExampleSet examples = createExampleSet();
  Network network = makeNetwork();

  Trainer trainer = new Trainer();
  trainer.addEpochEventListener(new StopOnErrorListener(0.05));
  trainer.addEpochEventListener(new MaxIterationsListener(1000));
  trainer.setTrainingExamples(examples);
  try {
    trainer.train(network);
  } catch (TrainingException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
  }
  System.out.println("Trained network in " + trainer.getEpochCount() + " epochs");
  System.out.println("With an error of " + trainer.getLastError() * 100 + "%");
}