I am writing a neural net in Java, and I'm having trouble with an ArrayList.get() not returning a variable.
double train(ArrayList<Double> inputVector, double desiredOutput) {
double result = output(inputVector);
double error = desiredOutput - result;
double delta = learningRate_ * error * result * (1.0 - result);
for (int i = 0; i < outputLayer_.weights_.size(); i++) {
outputLayer_.weights_.get(i).doubleValue() += delta * lastOutput_.get(i);
}
ArrayList<Double> hiddenDelta = new ArrayList<Double>();
for (int j = 0; j < hiddenLayer_.size(); j++) {
double HiddenDelta = delta * outputLayer_.weights_.get(j + 1) * lastOutput_.get(j + 1) * (1 - lastOutput_.get(j + 1));
for (int l = 0; l < hiddenLayer_.get(j).weights_.size(); l++) {
hiddenLayer_.get(j).weights_.get(l) += HiddenDelta * inputVector.get(l);
}
}
The Error I get is on both of the lines that try to +=, each inside a for loop (1st and third) It tells me that a variable is expected. I am using JDK 8, with Intellij. I used the following to create the weights list:
ArrayList<Double> weights_ = new ArrayList<Double>();
Every List is initialized in a similar form.