Question
Appendix C. Matlab Program for a 2-n1-1 Neuron Network Model % MISO FF Neuron mapping % ECE/SYS 645 Intelligent Control Systems - Prof KaC Cheok,
Appendix C. Matlab Program for a 2-n1-1 Neuron Network Model
% MISO FF Neuron mapping
% ECE/SYS 645 Intelligent Control Systems - Prof KaC Cheok, 11 Jan '17
function HW2_P3_2_n1_1_fcn_2018
%% Initialize Weights & biases
clear all; close all; clc;
n1 = 20;
W1 = randn(n1,2); b1 = randn(n1,1);
W2 = ones(1,n1); b2 = randn(1);
u1 = -10:0.1:10; nCol = length(u1);
u2 = -5:0.1:5; nRow = length(u2);
y = zeros(nRow,nCol);
%% FFNN surface
actfcn = 'radbas'; % logsig, tansig, radbas
tic
for i = 1:nRow;
u = [u1; u2(i)*ones(size(u1))] ;
y(i,:) = FNN_2n1_fcnfcn(W1,b1,W2,b2,u,actfcn);
end
toc
%% Plot
figure(1); mesh(u1,u2,y);
xlabel('u1'); ylabel('u2'); zlabel('y');grid on;
[n1,n0] = size(W1); n2 = size(W2,1);
title([num2str(n0),'-',num2str(n1),'-',num2str(n2),' FNN with ',actfcn,'-purelin']);
end
%%
function y2 = FNN_2n1_fcnfcn(W1,b1,W2,b2,u,actfcn)
% s1 = W1*u + B1; y1 = f1(s1); s2 = W2*y1 + B2; y2 = f2(s2);
s1 = W1*u + b1*ones(1,size(u,2));
switch actfcn
case 'radbas', y1 = radbas(s1);
case 'tansig', y1 = tansig(s1);
case 'logsig', y1 = logsig(s1);
end
y2 = W2*y1 + b2;
end
. Problem 4: Unanticipatable 3-layer FNN (25%) Modify the 2-layer FNN program in Appendix C so as to generate the input-output of the 3-layer FNN. H W = n, x2 by =n x1 W2 = n2 x n b2 = n2 x1 $i = Wju+b; y = radbas(s) S2 = W2y + b2 y2 = tan sig(sz) S3 =W3y2 + b3 Yz = purelin(sz) W3 = 1x n2 bz = 1x1 Consider a 2-10-5-1 FNN, use random matrices & vectors for the weights and biases and produce the ul-u2-y3 map as done in the earlier problems. Note: The mapping can be more complicated and not anticipatable in nature. + . Problem 4: Unanticipatable 3-layer FNN (25%) Modify the 2-layer FNN program in Appendix C so as to generate the input-output of the 3-layer FNN. H W = n, x2 by =n x1 W2 = n2 x n b2 = n2 x1 $i = Wju+b; y = radbas(s) S2 = W2y + b2 y2 = tan sig(sz) S3 =W3y2 + b3 Yz = purelin(sz) W3 = 1x n2 bz = 1x1 Consider a 2-10-5-1 FNN, use random matrices & vectors for the weights and biases and produce the ul-u2-y3 map as done in the earlier problems. Note: The mapping can be more complicated and not anticipatable in nature. +Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started