Program: 32185
Project: 32185
Buggy source:
@Test public void resilientPropagationTest(){
  double[] gradientError=new double[NUM_EPOCHS];
  double[] ecogError=new double[NUM_EPOCHS];
  network.reset();
  weights=network.getFlat().getWeights();
  MLDataSet[] subsets=splitDataSet(training);
  Gradient[] workers=new Gradient[numSplit];
  Weight weightCalculator=null;
  for (int i=0; i < workers.length; i++) {
    workers[i]=initGradient(subsets[i]);
    workers[i].setWeights(weights);
  }
  log.info("String_Node_Str");
  NNParams globalParams=new NNParams();
  globalParams.setWeights(weights);
  for (int i=0; i < NUM_EPOCHS; i++) {
    double error=0.0;
    for (int j=0; j < workers.length; j++) {
      workers[j].run();
      error+=workers[j].getError();
    }
    gradientError[i]=error / workers.length;
    log.info("String_Node_Str" + i + "String_Node_Str"+ gradientError[i]);
    globalParams.reset();
    for (int j=0; j < workers.length; j++) {
      globalParams.accumulateGradients(workers[j].getGradients());
      globalParams.accumulateTrainSize(subsets[j].getRecordCount());
    }
    if (weightCalculator == null) {
      weightCalculator=new Weight(globalParams.getGradients().length,globalParams.getTrainSize(),this.rate,NNUtils.RESILIENTPROPAGATION);
    }
    double[] interWeight=weightCalculator.calculateWeights(globalParams.getWeights(),globalParams.getGradients());
    globalParams.setWeights(interWeight);
    for (int j=0; j < workers.length; j++) {
      workers[j].setWeights(interWeight);
    }
  }
  network.reset();
  network.getFlat().setWeights(weights);
  Propagation p=null;
  p=new ResilientPropagation(network,training);
  p.setThreadCount(numSplit);
  for (int i=0; i < NUM_EPOCHS; i++) {
    p.iteration(1);
    ecogError[i]=p.getError();
  }
  double diff=0.0;
  for (int i=0; i < NUM_EPOCHS; i++) {
    diff+=Math.abs(ecogError[i] - gradientError[i]);
  }
  Assert.assertTrue(diff / NUM_EPOCHS < 0.5);
}

Fixed version (ground truth):
@Test public void resilientPropagationTest(){
  double[] gradientError=new double[NUM_EPOCHS];
  double[] ecogError=new double[NUM_EPOCHS];
  network.reset();
  weights=network.getFlat().getWeights();
  MLDataSet[] subsets=splitDataSet(training);
  Gradient[] workers=new Gradient[numSplit];
  Weight weightCalculator=null;
  for (int i=0; i < workers.length; i++) {
    workers[i]=initGradient(subsets[i]);
    workers[i].setWeights(weights);
  }
  log.info("String_Node_Str");
  NNParams globalParams=new NNParams();
  globalParams.setWeights(weights);
  for (int i=0; i < NUM_EPOCHS; i++) {
    double error=0.0;
    for (int j=0; j < workers.length; j++) {
      workers[j].run();
      error+=workers[j].getError();
    }
    gradientError[i]=error / workers.length;
    log.info("String_Node_Str" + i + "String_Node_Str"+ gradientError[i]);
    globalParams.reset();
    for (int j=0; j < workers.length; j++) {
      globalParams.accumulateGradients(workers[j].getGradients());
      globalParams.accumulateTrainSize(subsets[j].getRecordCount());
    }
    if (weightCalculator == null) {
      weightCalculator=new Weight(globalParams.getGradients().length,globalParams.getTrainSize(),this.rate,NNUtils.RESILIENTPROPAGATION);
    }
    double[] interWeight=weightCalculator.calculateWeights(globalParams.getWeights(),globalParams.getGradients());
    globalParams.setWeights(interWeight);
    for (int j=0; j < workers.length; j++) {
      workers[j].setWeights(interWeight);
    }
  }
  network.reset();
  network.getFlat().setWeights(weights);
  Propagation p=null;
  p=new ResilientPropagation(network,training);
  p.setThreadCount(numSplit);
  for (int i=0; i < NUM_EPOCHS; i++) {
    p.iteration(1);
    ecogError[i]=p.getError();
  }
  double diff=0.0;
  for (int i=0; i < NUM_EPOCHS; i++) {
    diff+=Math.abs(ecogError[i] - gradientError[i]);
  }
  Assert.assertTrue(diff / NUM_EPOCHS < 0.2);
}