I have a for loop in my code that's giving an error on the entire loop itself, saying it's "unreachable code". I'm completely unsure about what's causing this with this loop:
public ArrayList<Double> Update(ArrayList<Double> addInputs)
{
// stores the resultant outputs from each layer
ArrayList<Double> outputs = null;
int cWeight = 0;
// first check that we have the correct amount of inputs
if (addInputs.size() != numInputs);
{
// just return an empty vector if incorrect
return outputs;
}
// For each layer....
for (int i = 0; i < numHiddenLayers + 1; ++i)
{
if (i > 0)
{
addInputs = outputs;
}
outputs.clear();
cWeight = 0;
// for each neuron sum the (inputs * corresponding weights) .Throw
// the total at our sigmoid function to get the output.
for (int j = 0; j < neuronLayers.get(i).numNeurons; ++j)
{
double netinput = 0;
int numberInputs = neuronLayers.get(i).listNeurons.get(j).numInputs;
// for each weight
for (int k = 0; k < numberInputs - 1; ++k)
{
// sum the weights x inputs
netinput += neuronLayers.get(i).listNeurons.get(j).weights.get(k) *
addInputs.get(cWeight++);
}
// add in the bias
netinput += neuronLayers.get(i).listNeurons.get(j).weights.get(numberInputs - 1)
* dBias;
// we can store the outputs from each layer as we generate them.
// the combined activation is first filtered through the sigmoid
//function
outputs.add(sigmoid(netinput,dActivationResponse));
}
}
It's claiming the entire for loop after
// For each layer....
is unreachable code. Any help would be greatly appreciated.
You have a semicolon here, so the method is always returning outputs
. Just remove it
if (addInputs.size() != numInputs); // <---- this one
{
// just return an empty vector if incorrect
return outputs;
}