I want to create a function that calculates neural network output. The elements of my NN is a 19D input vector and a 19D output vector. I choose one hidden layer with 50 neurons. My code is the following but i am not quite sure if it works properly.
double *BuildPlanner::neural_tactics(){
norm(); //normalize input vector
ReadFromFile(); // load weights W1 W2 b1
double hiddenLayer [50][1];
for(int h=0; h<50; h++){
hiddenLayer[h][0] =0;
for(int f = 0; f < 19; f++){
hiddenLayer[h][0] = hiddenLayer[h][0] + W1[h][f]*input1[f][0];
}
}
double HiddenLayer[50][1];
for(int h=0; h<50; h++){
HiddenLayer[h][0] = tanh(hiddenLayer[h][0] + b1[h][0]);
}
double outputLayer[50][1];
for(int h=0; h<19; h++){
for(int k=0; k<50; k++){
outputLayer[h][0] = outputLayer[h][0] + W2[h][k]*HiddenLayer[k][0];
}
}
double Output[19];
for(int h=0; h<19; h++){
Output[h] = tanh(outputLayer[h][0]);
}
return Output;
}
Actually I not quite sure about the matrices multiplication. W1*input+b1 where the size of the matrices are 50x19 * 19x1 + 50x1 and W2*outHiddenLayer 19x50*50x1!