Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- clear all
- % these are the values in the3 notes x(1), y(1)
- x_input = -5:1:10;
- y_input = 5*x_input.*x_input + 7*x_input + sqrt(13);
- % column vector
- y_input=y_input';
- x_input=x_input';
- M = length(x_input); % data pairs
- % x|y
- % ------
- % x(1)|(y1)
- x = -10:0.1:10;
- % see notes why
- w1_11 = 1;
- b1_1 = 2.5;
- w1_12 = 1;
- b1_2 = -2.5;
- w1_13 = 1;
- b1_3 = -7.5;
- % we're going to solve for these
- % w_11 = 600;
- % w_21 = -600;
- % b_1 = 600;
- for i=1:M
- phi(:,i) = [1/(1+exp(-(x_input(i)*w1_11+b1_1)));...
- 1/(1+exp(-(x_input(i)*w1_12+b1_2)));...
- 1/(1+exp(-(x_input(i)*w1_13+b1_3)));...
- 1];
- end
- Phi=phi'
- theta = Phi\y_input;
- w_11 = theta(1);
- w_21 = theta(2);
- w_31 = theta(3);
- b_1 = theta(4);
- y1 = Phi*theta;
- xbar1_1 = w1_11*x + b1_1;
- y1_1 = 1./(1+ exp(-xbar1_1));
- xbar1_2 = w1_12*x + b1_2;
- y1_2 = 1./(1+ exp(-xbar1_2));
- xbar1 = y1_1*w_11 + y1_2*w_21 + b_1;
- %y1 = xbar1;
- grid on;
- figure (2)
- plot(x_input,y_input,'r.-');
- hold on;
- plot(x_input,y1,'b.-');
- hold off;
- grid on
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement