0% found this document useful (0 votes)
84 views7 pages

Lab Neural Network No Answer

The document provides a series of MATLAB commands for creating and training various types of neural networks, including Multi-Layer Perceptrons, Single Layer Perceptrons, Competitive Networks, and Learning Vector Quantization. It demonstrates how to initialize networks, simulate outputs, plot results, and adjust training parameters. Additionally, it mentions the use of the Neural Network Toolbox graphical user interface.

Uploaded by

alokbdas
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
84 views7 pages

Lab Neural Network No Answer

The document provides a series of MATLAB commands for creating and training various types of neural networks, including Multi-Layer Perceptrons, Single Layer Perceptrons, Competitive Networks, and Learning Vector Quantization. It demonstrates how to initialize networks, simulate outputs, plot results, and adjust training parameters. Additionally, it mentions the use of the Neural Network Toolbox graphical user interface.

Uploaded by

alokbdas
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 7

>> help

MULTI LAYER PERCEPTRON


>> p = [-2:0.1:2]
>> t = 1+sin(pi*p/4)
>> plot(p, t)
>> sample = newff([-2 2], [2 1], {'logsig', 'purelin'})
>> sample.iw{1,1}
>> sample.lw{2,1}
>> sample.b{1,1}
>> sample.b{2,1}
>> y = sim(sample,p)
>> plot(p,t,p,y,'o')
>> sample.trainParam.epochs = 50;
>> sample = train(sample,p,t)
>> sample.iw{1,1}
>> sample.lw{2,1}
>> sample.b{1,1}
>> sample.b{2,1}
>> y1 = sim(sample,p)
>> plot(p,t,p,y1,'o')
>> sample1 = newff([-2 2], [10 1], {'logsig', 'purelin'})
>> y2 = sim(sample1,p)
>> plot(p,t,p,y2,'o')
>> sample1.trainParam.epochs = 50;
>> sample1 = train(sample1,p,t)
>> y3 = sim(sample1,p)
>> plot(p,t,p,y3,'o')
>> t1 = 1+sin(2*pi*p)

>> plot(p,t1)
>> sample2 = newff([-2 2], [10 1], {'logsig', 'purelin'})
>> y4 = sim(sample2, p)
>> plot(p,t1,p,y4,'o')
>> sample2.trainParam.epochs = 50;
>> sample2 = train(sample2,p,t1)
>> y5 = sim(sample2, p)
>> plot(p,t1,p,y5,'o')
>> sample2.trainParam.epochs = 200;
>> sample2 = train(sample2,p,t1)
>> y6 = sim(sample2, p)
>> plot(p,t1,p,y6,'o')
>> sample3 = newff([-2 2], [5 1], {'logsig', 'purelin'})
>> y7 = sim(sample3, p)
>> plot(p,t1,p,y7,'o')
>> sample3 = train(sample3,p,t1)
>> y8 = sim(sample3, p)
>> plot(p,t1,p,y8,'o')
>> x = [-2: 0.1: 2]
>> y = [-2: 0.1: 2]
>> z = x.*y
>> plot3(x,y,z)
>> sample3 = newff([-2 2; -2 2], [10 1], {'logsig', 'purelin'})
>> in1 = [x; y]
>> y9 = sim(sample3, in1)
>> plot3(x,y,y9)
>> sample3 = train(sample3,in1,z)
>> y10 = sim(sample3, in1)

>> plot3(x,y,y10)

SINGLE LAYER PERCEPTRON


>> Pper = [0 0 1 1; 0 1 0 1]

>> Tper = [0 0 0 1]
>> plotpv(Pper, Tper)
>> sampleper = newp([0 1; 0 1], 1)
>> Yper = sim(sampleper, Pper)
>> plotpv(Pper, Yper)
>> sampleper.iw{1,1}
>> sampleper.b{1}
>> plotpc(sampleper.iw{1,1}, sampleper.b{1})
>> sampleper.trainParam.epochs = 20;
>> sampleper = train(sampleper, Pper, Tper)
>> Yper1 = sim(sampleper, Pper)
>> plotpv(Pper, Yper1)
>> sampleper.iw{1,1}
>> sampleper.b{1}
>> plotpc(sampleper.iw{1,1}, sampleper.b{1})
>> Pper = [0 0 1 1; 0 1 0 1]
>> Tor_nor = [0 1 1 1; 1 0 0 0]
>> plotpv(Pper, Tor_nor(1,:))
>> figure(2)
>> plotpv(Pper, Tor_nor(2,:))
>> sampleper1 = newp([0 1; 0 1], 2)
>> Yper2 = sim(sampleper1, Pper)
>> sampleper1 = train(sampleper1, Pper, Tor_nor)
>> Yper3 = sim(sampleper1, Pper)
>> sampleper1.iw{1,1}
>> sampleper1.b{1,1}

Competitive Network
>> Pc = [1 1.1 0.9 -1 -0.8 -1.2; 1 0.8 1.2 -1 -0.9 -1.1]
>> samplec = newc([-2 2; -2 2], 2)
>> Yc = sim(samplec, Pc)

>> yclass = vec2ind(Yc)


>> samplec.iw{1,1}
>> samplec.b{1,1}
>> samplec = train(samplec, Pc)
>> Yc1 = sim(samplec, Pc)
>> yclass1 = vec2ind(Yc1)
>> samplec.iw{1,1}
>> samplec.b{1,1}

LEARNING VECTOR QUANTIZATION


>> Plvq = [1 1.1 0.9 -1 -0.8 -1.2 0 -0.1 0.1; 1 0.8 1.2 -1 -0.9 -1.1 0 0.2 -0.2]
>> Tlvq = [1 1 1 1 1 1 2 2 2]
>> T = ind2vec(Tlvq)
>> samplelvq = newlvq(minmax(Plvq), 3, [.67 .33])

>> Ylvq = sim(samplelvq, Plvq)


>> Yc = vec2ind(Ylvq)
>> samplelvq = train(samplelvq, Plvq, T)
>> Ylvq1 = sim(samplelvq, Plvq)
>> Yc1 = vec2ind(Ylvq1)
>> samplelvq.iw{1,1}
>> samplelvq.lw{2,1}

NEURAL NETWORK TOOLBOX GRAPHICAL USER


INTERFACE
>> nntool

You might also like