ANN Matlab
ANN Matlab
ANN Matlab
in Matlab
Hany Ferdinando
a = f(Wp + b)
Neural Network in Matlab
Transfer Function
Multiple layers
Perceptrons in Matlab
Make the perceptrons with net = newp(PR,S,TF,LF)
PR = Rx2 matrix of min and max values for R input elements
S = number of output vector
TF = Transfer function, default = hardlim, other option = hardlims
LF = Learning function, default = learnp, other option = learnpn
where e = t - a
Compute manually
This
P = [0 0 1 1; 0 1 0 1];
T = [0 0 0 1];
0.9
bias_init = net.b{1}
net.trainParam.epochs = 20;
net = train(net,P,T);
weight_final = net.IW{1,1}
bias_final = net.b{1}
simulation = sim(net,P)
Training-Blue Goal-Black
0.8
0.7
0.6
0.5
0.4
0.3
0.2
0.1
0
3
6 Epochs
OR Gate in Perceptron
P = [0 0 1 1; 0 1 0 1];
T = [0 1 1 1];
bias_init = net.b{1}
net.trainParam.epochs = 20;
net = train(net,P,T);
weight_final = net.IW{1,1}
0.9
0.8
Training-Blue Goal-Black
Performance is 0, Goal is 0
0.7
0.6
0.5
0.4
0.3
bias_final = net.b{1}
0.2
simulation = sim(net,P)
0.1
0
0.5
1.5
2
4 Epochs
2.5
3.5
P = [0 0 1 1; 0 1 0 1];
T = [1 1 1 0];
0.9
bias_init = net.b{1}
net.trainParam.epochs = 20;
net = train(net,P,T);
weight_final = net.IW{1,1}
Training-Blue Goal-Black
0.8
0.7
0.6
0.5
0.4
0.3
bias_final = net.b{1}
0.2
simulation = sim(net,P)
0.1
0
3
6 Epochs
10
P = [0 0 1 1; 0 1 0 1];
T = [1 0 0 0];
0.9
bias_final = net.b{1}
simulation = sim(net,P)
Training-Blue Goal-Black
0.8
0.7
0.6
0.5
0.4
0.3
0.2
0.1
0
0.5
1.5
2
4 Epochs
2.5
3.5
11
Backpropagation in Matlab
Make the backpropagation with
net = newff(PR,[S1 S2...SNl],{TF1 TF2...TFNl},BTF,BLF,PF)
xk+1 = xk - kgk
Neural Network in Matlab
12
13