Advertisement
Guest User

Untitled

a guest
Jan 29th, 2020
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. clear all
  2. % these are the values in the3 notes x(1), y(1)
  3. x_input = -5:1:10;
  4. y_input = 5*x_input.*x_input + 7*x_input + sqrt(13);
  5. % column vector
  6. y_input=y_input';
  7. x_input=x_input';
  8. M = length(x_input); % data pairs
  9. % x|y
  10. % ------
  11. % x(1)|(y1)
  12.  
  13.  
  14.  
  15. x = -10:0.1:10;
  16.  
  17. % see notes why
  18. w1_11 = 1;
  19. b1_1 = 2.5;
  20.  
  21. w1_12 = 1;
  22. b1_2 = -2.5;
  23.  
  24.  
  25. w1_13 = 1;
  26. b1_3 = -7.5;
  27.  
  28. % we're going to solve for these
  29. % w_11 = 600;
  30. % w_21 = -600;
  31. % b_1 = 600;
  32.  
  33. for i=1:M
  34. phi(:,i) = [1/(1+exp(-(x_input(i)*w1_11+b1_1)));...
  35. 1/(1+exp(-(x_input(i)*w1_12+b1_2)));...
  36. 1/(1+exp(-(x_input(i)*w1_13+b1_3)));...
  37. 1];
  38. end
  39.  
  40. Phi=phi'
  41. theta = Phi\y_input;
  42.  
  43. w_11 = theta(1);
  44. w_21 = theta(2);
  45. w_31 = theta(3);
  46. b_1 = theta(4);
  47.  
  48. y1 = Phi*theta;
  49.  
  50. xbar1_1 = w1_11*x + b1_1;
  51. y1_1 = 1./(1+ exp(-xbar1_1));
  52.  
  53. xbar1_2 = w1_12*x + b1_2;
  54. y1_2 = 1./(1+ exp(-xbar1_2));
  55.  
  56. xbar1 = y1_1*w_11 + y1_2*w_21 + b_1;
  57. %y1 = xbar1;
  58.  
  59. grid on;
  60.  
  61. figure (2)
  62. plot(x_input,y_input,'r.-');
  63. hold on;
  64. plot(x_input,y1,'b.-');
  65. hold off;
  66. grid on
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement