Program: 31754
Project: 31754
Buggy source:
@Override public NNParams doCompute(MasterContext<NNParams,NNParams> context){
  if (context.isFirstIteration()) {
    NNParams params=null;
    if (this.isContinuousEnabled) {
      params=initOrRecoverParams(context);
    }
 else {
      params=initWeights();
      LOG.info("String_Node_Str");
    }
    this.globalNNParams.setWeights(params.getWeights());
    return params;
  }
  if (context.getWorkerResults() == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  double totalTestError=0;
  double totalTrainError=0;
  int size=0;
  this.globalNNParams.reset();
  long totalCount=0L;
  int totalWorkerCount=0;
  for (  NNParams nn : context.getWorkerResults()) {
    totalTestError+=nn.getTestError();
    totalTrainError+=nn.getTrainError();
    this.globalNNParams.accumulateGradients(nn.getGradients());
    this.globalNNParams.accumulateTrainSize(nn.getTrainSize());
    totalCount+=nn.getCount();
    totalWorkerCount+=nn.getWrCount();
    size++;
  }
  LOG.debug("String_Node_Str",this.globalNNParams.getGradients()[0]);
  LOG.debug("String_Node_Str",totalCount,totalWorkerCount);
  if (size == 0) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  if (this.weightCalculator == null) {
    this.learningRate=this.rawLearningRate;
    this.weightCalculator=new Weight(this.globalNNParams.getGradients().length,this.globalNNParams.getTrainSize(),learningRate,propagation,this.regularizedConstant,RegulationLevel.to(this.validParams.get(CommonConstants.REG_LEVEL_KEY)));
  }
 else {
    this.learningRate=this.learningRate * (1.0d - this.learningDecay);
    this.weightCalculator.setLearningRate(this.learningRate);
    this.weightCalculator.setNumTrainSize(this.globalNNParams.getTrainSize());
  }
  double[] oldWeights=Arrays.copyOf(this.globalNNParams.getWeights(),this.globalNNParams.getWeights().length);
  double[] weights=this.weightCalculator.calculateWeights(this.globalNNParams.getWeights(),this.globalNNParams.getGradients());
  this.globalNNParams.setWeights(weights);
  double currentTestError=totalTestError / totalWorkerCount;
  double currentTrainError=totalTrainError / totalWorkerCount;
  boolean vtTriggered=false;
  if (validationTolerance > 0d) {
    double weightSumSquare=0d;
    double diffWeightSumSquare=0d;
    for (int i=0; i < weights.length; i++) {
      weightSumSquare+=Math.pow(weights[i],2);
      diffWeightSumSquare+=Math.pow(weights[i] - oldWeights[i],2);
    }
    if (Math.pow(diffWeightSumSquare,0.5) < this.validationTolerance * Math.max(Math.pow(weightSumSquare,0.5),1d)) {
      LOG.info("String_Node_Str",Math.pow(diffWeightSumSquare,0.5),Math.pow(weightSumSquare,0.5),validationTolerance);
      vtTriggered=true;
    }
  }
  if (currentTestError < this.bestValidationError) {
    this.bestValidationError=currentTestError;
  }
  LOG.info("String_Node_Str",new Object[]{context.getCurrentIteration(),currentTrainError,currentTestError});
  NNParams params=new NNParams();
  params.setTrainError(currentTrainError);
  params.setTestError(currentTestError);
  params.setGradients(new double[0]);
  params.setWeights(weights);
  LOG.debug("String_Node_Str",params,context.getCurrentIteration());
  double avgErr=(currentTrainError + currentTestError) / 2;
  LOG.info("String_Node_Str",context.getCurrentIteration(),avgErr,convergenceThreshold);
  if (judger.judge(avgErr,convergenceThreshold) || vtTriggered) {
    LOG.info("String_Node_Str",context.getCurrentIteration());
    params.setHalt(true);
  }
 else {
    LOG.debug("String_Node_Str",context.getCurrentIteration());
  }
  return params;
}

Fixed version (ground truth):
@Override public NNParams doCompute(MasterContext<NNParams,NNParams> context){
  if (context.isFirstIteration()) {
    NNParams params=null;
    if (this.isContinuousEnabled) {
      params=initOrRecoverParams(context);
    }
 else {
      params=initWeights();
      LOG.info("String_Node_Str");
    }
    this.globalNNParams.setWeights(params.getWeights());
    return params;
  }
  if (context.getWorkerResults() == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  double totalTestError=0;
  double totalTrainError=0;
  int size=0;
  this.globalNNParams.reset();
  long totalCount=0L;
  int totalWorkerCount=0;
  for (  NNParams nn : context.getWorkerResults()) {
    totalTestError+=nn.getTestError();
    totalTrainError+=nn.getTrainError();
    this.globalNNParams.accumulateGradients(nn.getGradients());
    this.globalNNParams.accumulateTrainSize(nn.getTrainSize());
    totalCount+=nn.getCount();
    totalWorkerCount+=nn.getWrCount();
    size++;
  }
  LOG.debug("String_Node_Str",this.globalNNParams.getGradients()[0]);
  LOG.debug("String_Node_Str",totalCount,totalWorkerCount);
  if (size == 0) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  if (this.weightCalculator == null) {
    this.learningRate=this.rawLearningRate;
    this.weightCalculator=new Weight(this.globalNNParams.getGradients().length,this.globalNNParams.getTrainSize(),learningRate,propagation,this.regularizedConstant,RegulationLevel.to(this.validParams.get(CommonConstants.REG_LEVEL_KEY)),this.dropoutRate);
  }
 else {
    this.learningRate=this.learningRate * (1.0d - this.learningDecay);
    this.weightCalculator.setLearningRate(this.learningRate);
    this.weightCalculator.setNumTrainSize(this.globalNNParams.getTrainSize());
  }
  double[] oldWeights=Arrays.copyOf(this.globalNNParams.getWeights(),this.globalNNParams.getWeights().length);
  double[] weights=this.weightCalculator.calculateWeights(this.globalNNParams.getWeights(),this.globalNNParams.getGradients());
  this.globalNNParams.setWeights(weights);
  double currentTestError=totalTestError / totalWorkerCount;
  double currentTrainError=totalTrainError / totalWorkerCount;
  boolean vtTriggered=false;
  if (validationTolerance > 0d) {
    double weightSumSquare=0d;
    double diffWeightSumSquare=0d;
    for (int i=0; i < weights.length; i++) {
      weightSumSquare+=Math.pow(weights[i],2);
      diffWeightSumSquare+=Math.pow(weights[i] - oldWeights[i],2);
    }
    if (Math.pow(diffWeightSumSquare,0.5) < this.validationTolerance * Math.max(Math.pow(weightSumSquare,0.5),1d)) {
      LOG.info("String_Node_Str",Math.pow(diffWeightSumSquare,0.5),Math.pow(weightSumSquare,0.5),validationTolerance);
      vtTriggered=true;
    }
  }
  if (currentTestError < this.bestValidationError) {
    this.bestValidationError=currentTestError;
  }
  LOG.info("String_Node_Str",new Object[]{context.getCurrentIteration(),currentTrainError,currentTestError});
  NNParams params=new NNParams();
  params.setTrainError(currentTrainError);
  params.setTestError(currentTestError);
  params.setGradients(new double[0]);
  params.setWeights(weights);
  LOG.debug("String_Node_Str",params,context.getCurrentIteration());
  double avgErr=(currentTrainError + currentTestError) / 2;
  LOG.info("String_Node_Str",context.getCurrentIteration(),avgErr,convergenceThreshold);
  if (judger.judge(avgErr,convergenceThreshold) || vtTriggered) {
    LOG.info("String_Node_Str",context.getCurrentIteration());
    params.setHalt(true);
  }
 else {
    LOG.debug("String_Node_Str",context.getCurrentIteration());
  }
  return params;
}