Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- n = -5:0.1:5;
- %plot(n, hardlim(n));
- %n = -5:0.1:5;
- %plot(n, purelin(n));
- %plot(n, tansig(n));
- %n = -5:0.1:5;
- %plot(n, logsig(n));
- %pojedynczy neuron, 2 wejscia
- % + jedno wejscie jest stale
- %argumenty newp:
- %zakresy danych wejsciowych
- %ilosc neuronow
- %funkcja
- %net = newp([-2 2; -2 2 ], 1, 'hardlim');
- %net = newp([-2 2; -2 2 ], 1, 'logsig');
- %net = newp([-2 2; -2 2 ], 1, 'purelin');
- %net = newp([-2 2; -2 2 ], 1, 'tansig');
- %net = newp([-2 2; -2 2 ], 1, 'hardlim');
- %net.IW{1, 1} = [ 1 1 ];
- %IW input wieght
- %pierwsza warstwa 4 neurony, druga 1
- %net=newff([0 3; 0 3 ], [ 4, 1 ], {'hardlim', 'hardlim'});
- net=newff([0 5; 0 5 ], [ 3, 1 ], {'hardlim', 'hardlim'});
- net.IW{1,1}= [-1 -3;-1 1; 3 1];
- net.b{1}=[13; 1; -7];
- net.LW{2,1}=[1,1,1];
- %druga warstwa waga
- net.b{2}=[-2.5];
- %net.b{1} = -1;
- %podanie wagi dla wejscia stalego (wyraz wolny)
- [ X Y ] = meshgrid(0:0.1:5);
- Z = X;
- %2 argumenty, siec i dane wejsciowe
- Z(:) = sim(net, [X(:)'; Y(:)']);
- surf(X,Y,Z);
- %za po moca pojedynczego neurona mozna zroibc linowy podzial przestrzeni
- %dzielmy tak, zeby kwadrat mial 1 a reszta plaszczyzny 0
- x=-1:0.05:1;
- x2=-1:0.01:1;
- y=sin(3*pi*x).^(2).*sin(pi*x);
- y2=sin(3*pi*x2).^(2).*sin(pi*x2);
- net=newff([-1 1],[30 1], {'tansig' 'purelin'}, 'trainlm');
- net.trainParam.epochs=500;
- net.trainParam.show=50;
- net.trainParam.goal=0.0000001;
- net=init(net);
- net=train(net, x, y);
- z = sim(net, x2);
- plot(x2, y2, 'r', x ,y, 'gO', x2, z, 'b');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement