I have created a neural network that feeds an image into a convolutional neural net, then feeds the flattened output of this network into an artificial neural network.
I have a feeling that my backward propagation is not working properly.
Mind you, I wrote all of it from scratch in vanilla javascript.
The final point of control for me as the programmer is when I input the desired output into the backwards propagation algorithm to calculate the deltas and update the weights. After running backwards propagation I run forward propagation with identical input data to the data that was put into the network before backward propagation to see the change in the output layer based on the new weight values.
For each individual output of my neural network's final layer if it is between the output before backward propagation and the desired output then the network successfully propagated backwards for that output. In my network I had 4 outputs. I took the average of how many outputs were correct for each time back propagation was run and on average I got 0.773206751. About 77% of the time the gradient moved in the correct direction. So 23% of the time the network returned an output in the incorrect direction or returned an output that surpassed the desired output(went too far in the right direction).
In a neural network after running backwards propagation should the output after back propagation be closer to the desired output 100% of the time? What could cause these types of inaccuracies(or are there too many potential causes)?
It is unfortunately a problem that I cannot debug(because there are too many small numbers to keep track of). Unless there is a way to debug this problem, but I'm not sure.
architecture
input to CNN[102, 102, 4]
conv: kernel[9*9] stride:3 output:[32, 32, 16] act: ReLU
conv: kernel[5*5] stride:3 output:[10, 10, 32] act: ReLU
max-pool: pool_dim[2*2] stride:2 output:[5, 5, 32]
flatten: from [5, 5, 32] to 800 neurons
inp layer: 800 neurons
hidden layer: [800, 402] act: ReLU
output layer: [402, 4] act: for first 3 in output softmax for the fourth in output linear.
it is an a2c network.
This question has been marked as a duplicate to questions concerning gradient descent. I am not asking about descent at all. I don't care how my output affects my error equation. What I care about is my network updating the weights properly. I input desired outputs and instruct the neural network to adjust the weights to get an output closer to the desired output. Then the network after the weights are updated given the SAME exact input does not approach desired output 23% of the time. This does not have to do with gradient descent because my error function's new output is not part of this problem. Matter of a fact here is the logic I use:
let a2cdeltas = actorCritic.backward(critic_loss, delayed_reward, actor_loss, last_actions[id]);
CNN_network.propagateBackward(a2cdeltas);
CNN_network.propagateForward(CNN_network.recent_input);
let NNO = actorCritic.forward(CNN_network.flatten());
let test = new Array(4);
let thisavg = 0;
for(let i = 0; i < NNO.length; i++)
{
if((NNO[i] > actualOutput[i] && NNO[i] < expectedOutput[i]) || (NNO[i] < actualOutput[i] && NNO[i] > expectedOutput[i]))
{
test[i] = true;
thisavg++;
}
else test[i] = false;
}
actualOutput = new Array;
expectedOutput = new Array;
avg_cnt++;
sum += thisavg/4;
avg = sum/avg_cnt;
console.log(avg);
As you can see I am directly checking to see if the new output after weights are updated are somewhere between the desired output and actual output before weights were updated. I am asking if my network is adjusting its weights properly. I am not asking if an error function increasing in error after an update means that I am not updating the weights correctly.
What I am saying is that the gradient might literally be moving in the wrong direction if my backward propagation is not working properly.