Beispiel #1
0
  /**
   * Initialize back propagator with the appropriate settings
   *
   * @return an initialized BackPropagator
   * @throws Exception
   */
  private BackPropagator initializeTrainer() throws Exception {
    BackPropagator trainer = new BackPropagator(_network, _learningRate);
    int trainingCount = _trainingSet.getCount();
    for (int i = 0; i < trainingCount; i++) {
      TrainingGrid t = _trainingSet.getGrid(i);
      trainer.addInputOutput(
          GridProcessor.convertGrid(t.getGrid()),
          GridProcessor.convertExpectedOutput(t.getValue()));
    }

    return trainer;
  }
Beispiel #2
0
  /**
   * Train the set Network with the set TrainingSet and learning rate for the set EpochCount times
   */
  @Override
  public Void doInBackground() {
    try {
      int progress = 0;
      BackPropagator trainer = initializeTrainer();

      setProgress(0);
      while (progress < _epochCount && !isCancelled()) {
        trainer.runAndUpdate();
        progress++;
        setProgress((100 * progress) / _epochCount);
      }
    } catch (Exception ex) {
      ex.printStackTrace();
    }

    return null;
  }