0

I am working on a neural net I keep getting a Matrix Dimensions Must Agree Error for the ex_sum accumulator in my for loop. I am not sure why because the matrixes being element wise multiplied are of equal dimensions. Can anyone explain why I might be getting this error??? Thanks in advance. (This is for multi-class classification with element-wise multiplication with a logic vector of size 10X1)

ex_sum = 0;

for i = 1:5000
  c = 1:10;
  output = c == y(i);
  ex_sum = ex_sum + sum(-output .* log(hypothesis(i,:)) - (1-output) .* log(1 - hypothesis(i,:)));
  end

J = 1/m * ex_sum;
adecyber
  • 1
  • 1
  • It doesn't matter if you're using a neural net. You're using the logistic regression cost function, and that's what the duplicate talks about. – rayryeng Jul 13 '17 at 01:07
  • Mine is different. I'm doing a multi class neural net that uses 10 by 1 logic vectors ("output" all 0s and 1s) instead of the 5,000 by 1 y vector of the different classes like the duplicate. Then I am doing an element wise multiplication instead of a vectorized multiplication. The element wise multiplication seems to be where I am getting an error, but I'm not sure why because both matrixes are of equal dimension. – adecyber Jul 13 '17 at 01:19

0 Answers0