Program: 25957
Project: 25957
Buggy source:
public void finalizeStructure(){
  final int layerCount=layers.size();
  this.inputCount=layers.get(0).getCount();
  this.outputCount=layers.get(layerCount - 1).getCount();
  this.layerCounts=new int[layerCount];
  this.layerContextCount=new int[layerCount];
  this.weightIndex=new int[layerCount];
  this.layerIndex=new int[layerCount];
  this.activationFunctions=new ActivationFunction[layerCount];
  this.layerFeedCounts=new int[layerCount];
  this.biasActivation=new double[layerCount];
  int index=0;
  int neuronCount=0;
  int weightCount=0;
  for (int i=layers.size() - 1; i >= 0; i--) {
    final Layer layer=layers.get(i);
    Layer nextLayer=null;
    if (i > 0) {
      nextLayer=layers.get(i - 1);
    }
    this.biasActivation[index]=1;
    this.layerCounts[index]=layer.getTotalCount();
    this.layerFeedCounts[index]=layer.getCount();
    this.activationFunctions[index]=layer.getActivation();
    neuronCount+=layer.getTotalCount();
    if (nextLayer != null) {
      weightCount+=layer.getCount() * nextLayer.getTotalCount();
    }
    if (index == 0) {
      this.weightIndex[index]=0;
      this.layerIndex[index]=0;
    }
 else {
      this.weightIndex[index]=this.weightIndex[index - 1] + (this.layerCounts[index] * this.layerFeedCounts[index - 1]);
      this.layerIndex[index]=this.layerIndex[index - 1] + this.layerCounts[index - 1];
    }
    int neuronIndex=0;
    for (int j=layers.size() - 1; j >= 0; j--) {
      neuronIndex+=layers.get(j).getTotalCount();
    }
    Layer prev=null;
    if (i < this.layers.size() - 1) {
      prev=this.layers.get(i + 1);
    }
    layer.finalizeStructure(this,index,prev,this.layerIndex[index],this.weightIndex[index],this.layerFeedCounts[index]);
    index++;
  }
  this.weights=new double[weightCount];
  this.layerOutput=new double[neuronCount];
  this.layerSums=new double[neuronCount];
  clearContext();
}

Fixed version (ground truth):
public void finalizeStructure(){
  final int layerCount=layers.size();
  this.inputCount=layers.get(0).getCount();
  this.outputCount=layers.get(layerCount - 1).getCount();
  this.layerCounts=new int[layerCount];
  this.weightIndex=new int[layerCount];
  this.layerIndex=new int[layerCount];
  this.layerFeedCounts=new int[layerCount];
  this.biasActivation=new double[layerCount];
  int index=0;
  int neuronCount=0;
  int weightCount=0;
  for (int i=layers.size() - 1; i >= 0; i--) {
    final Layer layer=layers.get(i);
    Layer nextLayer=null;
    if (i > 0) {
      nextLayer=layers.get(i - 1);
    }
    this.biasActivation[index]=1;
    this.layerCounts[index]=layer.getTotalCount();
    this.layerFeedCounts[index]=layer.getCount();
    neuronCount+=layer.getTotalCount();
    if (nextLayer != null) {
      weightCount+=layer.getCount() * nextLayer.getTotalCount();
    }
    if (index == 0) {
      this.weightIndex[index]=0;
      this.layerIndex[index]=0;
    }
 else {
      this.weightIndex[index]=this.weightIndex[index - 1] + (this.layerCounts[index] * this.layerFeedCounts[index - 1]);
      this.layerIndex[index]=this.layerIndex[index - 1] + this.layerCounts[index - 1];
    }
    int neuronIndex=0;
    for (int j=layers.size() - 1; j >= 0; j--) {
      neuronIndex+=layers.get(j).getTotalCount();
    }
    Layer prev=null;
    if (i < this.layers.size() - 1) {
      prev=this.layers.get(i + 1);
    }
    layer.finalizeStructure(this,index,prev,this.layerIndex[index],this.weightIndex[index],this.layerFeedCounts[index]);
    index++;
  }
  this.weights=new double[weightCount];
  this.layerOutput=new double[neuronCount];
  this.layerSums=new double[neuronCount];
  index=0;
  for (int i=0; i < this.layerIndex.length; i++) {
    final boolean hasBias=this.layerFeedCounts[i] != this.layerCounts[i];
    Arrays.fill(this.layerOutput,index,index + this.layerFeedCounts[i],0);
    index+=this.layerFeedCounts[i];
    if (hasBias) {
      this.layerOutput[index++]=this.biasActivation[i];
    }
  }
}