%% SOLUTIONS TO THE HOMEWORK, DEC 9 % Just as an overview, the mapping is taking points in R^2 and producing % points in R^3 using 5 centers. % % What are the sizes of our weights and bias vectors? The weight matrix W % takes a vector from R^5 and produces a vector in R^3, so W is 5 x 3, and % the bias vector (if there is one) is in R^3. % First the data: X=[1 0;0 1;1 1;-1 0]; T=[2 1 -1;1 1 1;1 1 0;-1 0 1]; C=2*randn(5,2); % Build the RBF E1=edm(X,C); Phi=rbf1(E1,1,1); % Use the Gaussian and width 1 W=pinv(Phi)*T % This weight matrix is 5 x 3 Y=Phi*W % Y is the model output. % Modification of the previous code to put in a bias: Phi01=[Phi,ones(4,1)]; % This is transposed from the usual to match sizes. W01=pinv(Phi01)*T % The bias is the last row of W01 (which is 6 x 3) % We can break it up: W=W01(1:5,:); b=W01(6,:)'; Y01=Phi*W+repmat(b',4,1) %% Problem 2: P=[1 2 3]; T=[2.0 4.1 5.9]; net=newrb(P,T); tt=linspace(1,3); yy=sim(net,tt); plot(P,T,'k*',tt,yy); % Find the weights and biases and centers. Verify the previous answer. Centers=net.IW{1,1}; W=net.LW{2,1} b=net.b{2}; scale1=net.b{1}; %Re-compute the output of the RBF and compare to Matlab A=edm(tt',Centers); A1=A.*repmat(scale1',100,1); Phi=rbf1(A1,1,1); Yout=W*Phi'+b; max(abs(yy-Yout)) %Biggest difference is?