vinayarun

Predict function code

Mar 16th, 2016
62
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function p = predict(Theta1, Theta2, X)
  2.  
  3. m = size(X, 1);
  4. num_labels = size(Theta2, 1);
  5.  
  6. p = zeros(size(X, 1), 1);
  7.  
  8. h1 = sigmoid([ones(m, 1) X] * Theta1');
  9. h2 = sigmoid([ones(m, 1) h1] * Theta2');
  10.  
  11. for i =1:size(h2,1)
  12.   if h2(i)>0.5
  13.     p(i) = 1;
  14.   else
  15.     p(i) = 0;
  16.   end
  17. end
  18.  
  19. end
RAW Paste Data