I ve got two matrices W2 and hiddenLayer and i want to proceed the multiplication of those. W2 size’s 12×50 and hiddenLayer size’s 50×1. The proper code for the above calculation:
for(int h=0; h<50; h++){
for(int k=0; k<12; k++){
outputLayer += W2[k][h]*HiddenLayer[h];
}
}
or i ve got to put at first k-for??
Matrix multiplication is defined as:
Thus
outputLayeris a vector. SinceHiddenLayeris a vector too, this isn’t really a matrix multiplication but a matrix vector multiplication, which simplifies the formula above:So all in all your code should be something like