NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

//---- funkcja XOR
//---- algorytm wstecznej propagacji bledu
clear all;
A(1,1)=1; A(1,2)=0; A(1,3)=0; A(1,4)=0;
A(2,1)=1; A(2,2)=0; A(2,3)=1; A(2,4)=1;
A(3,1)=1; A(3,2)=1; A(3,3)=0; A(3,4)=1;
A(4,1)=1; A(4,2)=1; A(4,3)=1; A(4,4)=0;
//---- wykreslenie obszaru klasyfikacji
Licz=0;
IleKrokow=50000;
mtlb_hold on;
for i=1:4
if A(i,4)==1
plot(A(i,2),A(i,3),'ko:');
else
plot(A(i,2),A(i,3),'r+:');
end
end
mtlb_axis([-0.4 1.4 -0.4 1.4]);
//---- utworzenie odpowiednich tablic na dane
W=zeros(1,9); S=zeros(1,3); U=zeros(1,3); F=zeros(1,3); d=zeros(1,3);
//---- losowa inicjalizacja wag poczatkowych
for i=1:9
W(i)=rand()-0.5;
end;
ro=0.2;
iteracja=0;
blad=0;
przypisz_blad=0;
err=zeros(2,IleKrokow);

while (iteracja<IleKrokow)
iteracja=iteracja+1;
//---- losowe wybieranie wektora trenujacego
i=round(rand()*3)+1;
//---- faza propagacji w przod - warstwa posrednia
S(1)=W(1)*A(i,1)+W(2)*A(i,2)+W(3)*A(i,3);
S(2)=W(4)*A(i,1)+W(5)*A(i,2)+W(6)*A(i,3);
U(1)=1/(1+exp(-S(1)));
U(2)=1/(1+exp(-S(2)));
//---- faza propagacji w przod - warstwa wyjsciowa
S(3)=W(7)*A(i,1)+W(8)*U(1)+W(9)*U(2);
U(3)=1/(1+exp(-S(3)));

//---- obliczenie błędu uczenia co 100 iteracji
if (modulo(iteracja,100) == 0)
for j=1:4
S1 = W(1) * A(j,1) + W(2) * A(j,2) + W(3) * A(j,3);
S2 = W(4) * A(j,1) + W(5) * A(j,2) + W(6) * A(j,3);
U1 = 1 / (1 + exp(-S1));
U2 = 1 / (1 + exp(-S2));


S5 = 1 * W(7) + U1 * W(8) + U2 * W(9);
U5 = 1 / (1 + exp(-S5));

blad = blad + abs(A(j,4) - U5);
end
przypisz_blad = blad;
blad = 0;
end
//---- przypisanie wartości do tablicy zawierającej błędy uczenia
err(1,iteracja) = iteracja;
err(2,iteracja) = przypisz_blad;
//---- faza propagacji wstecz - warstwa wyjsciowa
F(3)=U(3)*(1-U(3));
d(3)=(A(i,4)-U(3))*F(3);
//---- faza propagacji wstecz - warstwa posrednia
F(1)=U(1)*(1-U(1));
d(1)=W(8)*d(3)*F(1);
F(2)=U(2)*(1-U(2));
d(2)=W(9)*d(3)*F(2);
//---- uaktualnienie wag - warstwa wyjsciowa
W(7)=W(7)+(ro*d(3)*A(i,1));
W(8)=W(8)+(ro*d(3)*U(1));
W(9)=W(9)+(ro*d(3)*U(2));
//---- uaktualnienie wag - warstwa posrednia
W(1)=W(1)+(ro*d(1)*A(i,1));
W(2)=W(2)+(ro*d(1)*A(i,2));
W(3)=W(3)+(ro*d(1)*A(i,3));
W(4)=W(4)+(ro*d(2)*A(i,1));
W(5)=W(5)+(ro*d(2)*A(i,2));
W(6)=W(6)+(ro*d(2)*A(i,3));
end;
//---- wykreslenie otrzymanej linii podzialu (neuron 1)
k=0;
for i=-2:0.01:2
k=k+1;
XX(k)=i;
YY(k)=-((W(2)/W(3))*i)-(W(1)*1)/W(3);
end
plot(XX,YY,'r');
//---- wykreslenie otrzymanej linii podzialu (neuron 2)
k=0;
for i=-2:0.01:2
k=k+1;
XX(k)=i;
YY(k)=-((W(5)/W(6))*i)-(W(4)*1)/W(6);
end
plot(XX,YY,'b');
mtlb_axis([-0.4 1.4 -0.4 1.4]);
disp(W);
mtlb_hold on;
//wykreslenie bledu uczenia

mtlb_axis([0 10 0 3]);
plot(err(1,:),err(2,:),'blue');


//u1 = input('Podaj u1:');
//u2 = input('Podaj u2:');

u1=1;
u2=0;

S3 = 1 * W(1) + u1 * W(2) + u2 * W(3);
U3 = 1 / (1 + exp(-S3));

S4 = 1 * W(4) + u1 * W(5) + u2 * W(6);
U4 = 1 / (1 + exp(-S4));

S5 = 1 * W(7) + U3 * W(8) + U4 * W(9);
U5 = 1 / (1 + exp(-S5));

disp(U5,'U5 = ');
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.