Penuntun Praktikum
J
J
a
a
r
r
i
i
n
n
g
g
a
a
n
n
S
S
y
y
a
a
r
r
a
a
f
f
T
T
i
i
r
r
u
u
a
a
n
n
D
D
e
e
n
n
g
g
a
a
n
n
M
M
a
a
t
t
l
l
a
a
b
b
G
G
U
U
I
I
IGA Widagda
Fisika FMIPA UNUD
2014
JST Hebb
1.1 Program Aplikasi Komputer JST Hebb
1.1.1.Rancangan Graphical User Interface (GUI)
1.1.2 Daftar Komponen
No
Komponen
Properti
1
Panel
title
Training
2
Axes
Tag
axes1
3
Axes
Tag
axes2
4
Axes
Tag
axes6
5
Axes
Tag
axes7
6
Axes
Tag
axes8
7
Push button
String
open image 1
Tag
image1_pushbutton
8
Push button
String
open image 2
Tag
image2_pushbutton
9
Push button
String
open image 3
Tag
image3_pushbutton
10
Push button
String
open image 4
Tag
image4_pushbutton
11
Push button
String
open image 5
Tag
image5_pushbutton
1
1
Gambar 1.1 Rancangan GUI program aplikasi JST Hebb
1.1.3. Kode Program (source code)
1.1.3.1 Function
image1_pushbutton_Callback
function image1_pushbutton_Callback(hObject, eventdata, handles) [filename,pathname]=uigetfile('*.jpg;*.bmp;*.png','pilih gambar anda');
handles.image_file = strcat(pathname,filename); %"handles.image_file" var image_file %di set agar bisa diakses dari function
%yang lain
if exist(handles.image_file) % check if image exists
handles.im_original1=imread(handles.image_file); % read in the image axes(handles.axes1); % will display on axes1
imshow(handles.im_original1); else % if image doesn_t exist
imshow('file_not_found.jpg') % Display the _Error image_ end
guidata(hObject,handles);
1.1.3.2 Function
image2_pushbutton_Callback
function image2_pushbutton_Callback(hObject, eventdata, handles) [filename,pathname]=uigetfile('*.jpg;*.bmp;*.png','pilih gambar anda');
handles.image_file = strcat(pathname,filename); %"handles.image_file" var image_file %di set agar bisa diakses dari function
%yang lain
if exist(handles.image_file) % check if image exists
handles.im_original1=imread(handles.image_file); % read in the image axes(handles.axes2); % will display on axes2
imshow(handles.im_original1); else % if image doesn_t exist
imshow('file_not_found.jpg') % Display the _Error image_ end
guidata(hObject,handles);
No
Komponen
Properti
12
Static text
String
Bobot (w) dan Bias (b) hasil training
13
List box
String
kosong
Tag
Show_listbox
14
Push button
String
start training
Tag
start_training
15
Panel
Title
Testing
16
Axes
Tag
axes3
17
Axes
Tag
axes4
18
Push button
String
open testing image
Tag
image_testing_pushbutton
19
Push button
String
Start testing
Tag
start_testing_pushbutton
20
Static text
String
Hasil Testing
1.1.3.3 Function
image3_pushbutton_Callback
function image3_pushbutton_Callback(hObject, eventdata, handles) [filename,pathname]=uigetfile('*.jpg;*.bmp;*.png','pilih gambar anda');
handles.image_file = strcat(pathname,filename); %"handles.image_file" var image_file %di set agar bisa diakses dari function
%yang lain
if exist(handles.image_file) % check if image exists
handles.im_original1=imread(handles.image_file); % read in the image axes(handles.axes6); % will display on axes6
imshow(handles.im_original1); else % if image doesn_t exist
imshow('file_not_found.jpg') % Display the _Error image_ end
guidata(hObject,handles);
1.1.3.4 Function
image4_pushbutton_Callback
function image4_pushbutton_Callback(hObject, eventdata, handles) [filename,pathname]=uigetfile('*.jpg;*.bmp;*.png','pilih gambar anda');
handles.image_file = strcat(pathname,filename); %"handles.image_file" var image_file %di set agar bisa diakses dari function
%yang lain
if exist(handles.image_file) % check if image exists
handles.im_original1=imread(handles.image_file); % read in the image axes(handles.axes7); % will display on axes7
imshow(handles.im_original1); else % if image doesn_t exist
imshow('file_not_found.jpg') % Display the _Error image_ end
guidata(hObject,handles);
1.1.3.3 Function
image5_pushbutton_Callback
function image5_pushbutton_Callback(hObject, eventdata, handles) [filename,pathname]=uigetfile('*.jpg;*.bmp;*.png','pilih gambar anda');
handles.image_file = strcat(pathname,filename); %"handles.image_file" var image_file %di set agar bisa diakses dari function
%yang lain
if exist(handles.image_file) % check if image exists
handles.im_original1=imread(handles.image_file); % read in the image axes(handles.axes8); % will display on axes8
imshow(handles.im_original1); else % if image doesn_t exist
imshow('file_not_found.jpg') % Display the _Error image_ end
guidata(hObject,handles);
1.1.3.4 Function
start_training_pushbutton_Callback
function start_training_pushbutton_Callback(hObject, eventdata, handles) s1=rgb2gray(handles.im_original1); s2=rgb2gray(handles.im_original2); s3=rgb2gray(handles.im_original3); s4=rgb2gray(handles.im_original4); s5=rgb2gray(handles.im_original5);
%ubah data menjadi bipolar[1,-1] jml_baris=size(s1,1);
for i=1:1:jml_baris for j=1:1:jml_kolom if s1(i,j)>=200 %putih s1_temp(i,j)=-1; else %hitam s1_temp(i,j)=1; end end end for i=1:1:jml_baris for j=1:1:jml_kolom if s2(i,j)>=200 %putih s2_temp(i,j)=-1; else %hitam s2_temp(i,j)=1; end end end for i=1:1:jml_baris for j=1:1:jml_kolom if s3(i,j)>=200 %putih s3_temp(i,j)=-1; else %hitam s3_temp(i,j)=1; end end end for i=1:1:jml_baris for j=1:1:jml_kolom if s4(i,j)>=200 %putih s4_temp(i,j)=-1; else %hitam s4_temp(i,j)=1; end end end for i=1:1:jml_baris for j=1:1:jml_kolom if s5(i,j)>=200 %putih s5_temp(i,j)=-1; else %hitam s5_temp(i,j)=1; end end end %jml_pola= 5; % 5 citra
%ubah matrik jadi jadi matrik kovektor k=0; for i=1:1:jml_baris for j=1:1:jml_kolom k=k+1; s(1,k)=s1_temp(i,j); end end
t1=1; %target untuk citra 1 simpan sbg 3 kolom %akhir dalam array s
t2=1; t3=1;
s(1,k+1)=t1; s(1,k+2)=t2; s(1,k+3)=t3; k=0; for i=1:1:jml_baris for j=1:1:jml_kolom k=k+1; s(2,k)=s2_temp(i,j); end end t1=1;
t2=1; %target untuk citra 2 t3=-1; s(2,k+1) = t1; s(2,k+2)= t2; s(2,k+3)=t3; k=0; for i=1:1:jml_baris for j=1:1:jml_kolom k=k+1; s(3,k)=s3_temp(i,j); end end
t1=1; %target untuk citra 3 t2=-1; t3=1; s(3,k+1) = t1; s(3,k+2) = t2; s(3,k+3)= t3; k=0; for i=1:1:jml_baris for j=1:1:jml_kolom k=k+1; s(4,k)=s4_temp(i,j); end end
t1=1; %target untuk citra 4 t2=-1; t3=-1 s(4,k+1) = t1; s(4,k+2) = t2; s(4,k+3)= t3; k=0; for i=1:1:jml_baris for j=1:1:jml_kolom k=k+1; s(5,k)=s5_temp(i,j); end end
t1=-1; %target untuk citra 5 t2= 1; t3= 1; s(5,k+1) = t1; s(5,k+2) = t2; s(5,k+3) = t3;
%inisialisasi bobot (w) dan bias (b) jml_pola=size(s,1);
jml_input = size(s,2)-3; %-3 krn output/target ada 3 jml_output=3;
%inisialisasi botot w dan bias b for j=1:1:jml_output for i=1:1:jml_input w(i,j)=0; end end for j=1:1:jml_output b(j)=0; end for n=1:1:jml_pola for i=1:1:jml_input
x(i) = s(n,i); %%x(i) = s(i) end for j=1:1:jml_output t(n,j)=s(n,jml_input+j); %target t % t(n,2)=s(n,jml_input+2); %target t y(n,j)=t(n,j); % y1 % y(n,2)=t(n,2); % y2 end
%perbaiki bobot dan bias for j=1:1:jml_output for i=1:1:jml_input
w(i,j) = w(i,j) + x(i)*y(n,j); % w_baru =w_lama+x(i)* y handles.w_final(i,j)=w(i,j);
end
b(j)=b(j)+y(n,j); %b_baru= b_lama + y handles.b_final(j)=b(j);
end end
%%tampilkan bobot dan bias hasil pelatihan di command window for i=1:1:jml_input for j=1:1:jml_output disp(strcat('w',num2str(i),num2str(j),' = ',num2str(w(i,j)))); end end for j=1:1:jml_output disp(strcat('b',num2str(j),' = ',num2str(b(j)))); end
%Tampilkan bobot dalam list box n=1;
for i=1:1:jml_input %index dari array bobot w for j=1:1:jml_output
k(n)=str2num(strcat(num2str(i),num2str(j))); w_vek(n)=w(i,j); %ubah w jadi vektor w_vek n=n+1;
end end
%tampilkan bobot bj, sbg elemen terakhir listbox set(handles.show_listbox,'String',strcat('w',num2str(k'),' = ',num2str(w_vek'))); for j=1:1:jml_output bobot=strcat('b',num2str(j),' = ',num2str(b(j))); list_box_old=cellstr(get(handles.show_listbox,'String')); list_box_new= [list_box_old;{bobot}]; set(handles.show_listbox,'String',list_box_new) ;
end
guidata(hObject,handles);
1.1.3.5 Function
image_testing_pushbutton_Callback
function image_testing_pushbutton_Callback(hObject, eventdata, handles) [filename,pathname]=uigetfile('*.jpg;*.bmp;*.png','Select an Image File');
handles.image_file = strcat(pathname,filename); %"handles.image_file" var image_file %di set agar bisa diakses dari function
%yang lain
if exist(handles.image_file) % check if image exists
handles.im_testing=imread(handles.image_file); % read in the image axes(handles.axes3); % will display on axes1
imshow(handles.im_testing); else % if image doesn_t exist
imshow('file_not_found.jpg') % Display the _Error image_ end
guidata(hObject,handles);
1.1.3.6 Function
start_testing_pushbutton_Callback
function start_testing_pushbutton_Callback(hObject, eventdata, handles) s=rgb2gray(handles.im_testing);
%ubah data menjadi bipolar[1,-1] jml_baris=size(s,1); jml_kolom=size(s,2); for i=1:1:jml_baris for j=1:1:jml_kolom if s(i,j)>=200 %putih s_temp(i,j)=-1; else %hitam s_temp(i,j)=1; end end end
%ubah matrik citra 2 dimensi s_temp jadi vektor 1 dimensi s k=0; for i=1:1:jml_baris for j=1:1:jml_kolom k=k+1; s_vektor(k)=s_temp(i,j); end end jml_input = k; jml_output =3; net(1)=0; net(2)=0; net(3)=0; for j=1:1:jml_output for i=1:1:jml_input x(i)=s_vektor(i); net(j)=net(j)+x(i)*handles.w_final(i,j); end net(j)=net(j)+handles.b_final(j); end axes(handles.axes4);
imshow(handles.im_original1); else
if net(1)>=0 && net(2)>=0 && net(3)<0 imshow(handles.im_original2); else
if net(1)>=0 && net(2)<0 && net(3) >=0 imshow(handles.im_original3); else
if net(1)>=0 && net(2)<0 && net(3) <0 imshow(handles.im_original4); else
if net(1)<0 && net(2)>=0 && net(3) >=0 imshow(handles.im_original5); else imshow(handles.im_original5); end end end end end
1.1.4 Hasil Eksekusi (RUN) program
Hasil eksekusi program JST Hebb dapat dilihat dalam Gambar 1.2.
Cara kerja program :
- Buka file citra atau gambar dengan menekan tombol
open image 1
sampai
open
image 5
- Klik tombol Start Training, setelah menunggu beberapa saat sistem akan
menampilkan bobot (w) dan bias (b) hasil pelatihan list box
- Buka file citra atau gambar dengan menekan tombol open testing image
- Klik tombol Start Testing, selanjutnya akan ditampilkan citra hasil testing yang
cocok dengan citra yang diuji.
2.1 Program Aplikasi Komputer JST Hebb (model 2)
2.1.1.Rancangan Graphical User Interface (GUI)
2.1.2 Daftar Komponen
No
Komponen
Properti
1
Panel
Title
Training
2
Axes
Tag
axes1
3
Axes
Tag
axes2
4
Axes
Tag
axes3
5
Push button
String
open
Tag
image1_pushbutton
6
Push button
String
<
Tag
before_pushbutton
7
Push button
String
>
Tag
next_pushbutton
8
Push button
String
Start Training
Tag
start_trainning_pushbutton
9
Push button
String
open
Tag
image_testing_pushbutton
10
Push button
String
Start Testing
Tag
start_testing_pushbutton
2.1.3. Kode Program (source code)
2.1.3.1 Function
image1_pushbutton_Callback
function image1_pushbutton_Callback(hObject, eventdata, handles) current_dir=pwd; %getting current directory
handles.img_dir=uigetdir(current_dir,'Select directory'); %Selecting directory %where image saved
%Reading image files at one folder if exist(handles.img_dir)
cd(handles.img_dir); %change directory D = dir('*.jpg'); %list all image-file in directory
handles.img_original = cell(1,numel(D));%create 1 X numel(D) cell array of empty matrices
% numel(D)=number of element in directory D for i = 1:numel(D)
[handles.img_original{i},handles.fs{i}] = imread(D(i).name); %save into array 'img_original' end axes(handles.axes1); for i=1:numel(D) imshow(handles.img_original{i}); end handles.number_of_image=numel(D); handles.number_of_max=numel(D); else
h=msgbox('File not found', 'Warning','error'); end
cd(current_dir);%return into current directory
guidata(hObject,handles);
2.1.3.2 Function
before_pushbutton_Callback
function before_pushbutton_Callback(hObject, eventdata, handles) axes(handles.axes1); % will display on axes1
i=handles.number_of_image; if i==1 % before_pushbutton.Enable='off'; imshow(handles.img_original{1}); %handles.number_of_img=1; else imshow(handles.img_original{i}); handles.number_of_image = handles.number_of_image-1;
No
Komponen
Properti
11
Static text
String
Database Citra
12
Static text2
String
Weight (w) dan Bias (b)
13
List box
String
kosong
Tag
show_listbox
14
Panel
Title
Testing
25
Static text
String
Hasil Testing
end
guidata(hObject,handles);
2.1.3.3 Function
next_pushbutton_Callback
function next_pushbutton_Callback(hObject, eventdata, handles) axes(handles.axes1); % will display on axes1
i=handles.number_of_image; if i == handles.number_of_max imshow(handles.img_original{i}); else imshow(handles.img_original{i}); handles.number_of_image = handles.number_of_image+1; end guidata(hObject,handles);
2.1.3.4 Function
start_trainning_pushbutton_Callback
function start_trainning_pushbutton_Callback(hObject, eventdata, handles) num_wav=size(handles.img_original,2); %number of wav files
for i=1:1:num_wav s(i,:,:)=rgb2gray(handles.img_original{i}); end jml_citra=size(s,1); jml_baris=size(s,2) jml_kolom=size(s,3)
%ubah citra asli bw menjadi bipolar[1,-1] for k=1:1:jml_citra for i=1:1:jml_baris for j=1:1:jml_kolom if s(k,i,j)>200 %putih s_temp(k,i,j)=-1; else %hitam s_temp(k,i,j)=1; end end end end
%ubah citra 'source' format matrik baris kolom(i,j) jadi format baris %citra 1 for m=1:1:jml_citra k=0; for i=1:1:jml_baris for j=1:1:jml_kolom k=k+1; s(m,k)=s_temp(m,i,j); end end end jml_input=k
%tentukan matrik target
handles.jml_target = 3; % 2^handles.jml_target jml_digit=handles.jml_target;
i=2^handles.jml_target-1; for k=1:num_wav
x=de2bi(i,jml_digit); %desimal to biner, tampilkan sebanyak 'jumlah digit' handles.target(k,:)=x;
i=i-1; end
%ubah target menjadi bipolar for k=1:num_wav for i=1:jml_digit if handles.target(k,i)==0 handles.target(k,i)=1; else handles.target(k,i)=-1; end end end
%inisialisasi bobot (w) dan bias (b) jml_pola=size(s,1)
%jml_input = size(s,2)
jml_output=handles.jml_target; %inisialisasi botot w dan bias b for j=1:1:jml_output for i=1:1:jml_input w(i,j)=0; end end for j=1:1:jml_output b(j)=0; end for n=1:1:jml_pola for i=1:1:jml_input
x(i) = s(n,i); %%x(i) = s(i) end for j=1:1:jml_output %t(n,j)=s(n,jml_input+j); %target t % t(n,2)=s(n,jml_input+2); %target t y(n,j)=handles.target(n,j); % y1 % y(n,2)=t(n,2); % y2 end
%perbaiki bobot dan bias for j=1:1:jml_output for i=1:1:jml_input
w(i,j) = w(i,j) + x(i)*y(n,j); % w_baru =w_lama+x(i)* y handles.w_final(i,j)=w(i,j);
end
b(j)=b(j)+y(n,j); %b_baru= b_lama + y handles.b_final(j)=b(j);
end end
%Tampilkan bobot dalam list box n=1;
for i=1:1:jml_input %index dari array bobot w for j=1:1:jml_output
k(n)=str2num(strcat(num2str(i),num2str(j))); w_vek(n)=w(i,j); %ubah w jadi vektor w_vek n=n+1;
end end
%tampilkan bobot bj, sbg elemen terakhir listbox
set(handles.show_listbox,'String',strcat('w',num2str(k'),' = ',num2str(w_vek'))); for j=1:1:jml_output bobot=strcat('b',num2str(j),' = ',num2str(b(j))); list_box_old=cellstr(get(handles.show_listbox,'String')); list_box_new= [list_box_old;{bobot}]; set(handles.show_listbox,'String',list_box_new) ; end guidata(hObject,handles);
2.1.3.3 Function
image_testing_pushbutton_Callback
function image_testing_pushbutton_Callback(hObject, eventdata, handles) [filename,pathname]=uigetfile('*.jpg','Pilih file citra(*.jpg)');
handles.img_file = strcat(pathname,filename); if exist(handles.img_file) % check if image exists axes(handles.axes2); % will display on axes1
handles.img_testing=imread(strcat(pathname,filename)); %read image imshow(handles.img_testing);
else % if image doesn_t exist
h=msgbox('file not found', 'Error','error'); end
handles.pathname=pathname; handles.filename=filename; guidata(hObject,handles);
2.1.3.4 Function
start_testing_pushbutton_Callback
function start_testing_pushbutton_Callback(hObject, eventdata, handles) s=rgb2gray(handles.img_testing);
%ubah data menjadi bipolar[1,-1] jml_baris=size(s,1); jml_kolom=size(s,2); for i=1:1:jml_baris for j=1:1:jml_kolom if s(i,j)>200 %putih s_temp(i,j)=-1; else %hitam s_temp(i,j)=1; end end end s_temp
%ubah matrik citra baris-kolom s_temp jadi matrik baris k=0; for i=1:1:jml_baris for j=1:1:jml_kolom k=k+1; s_vektor(k)=s_temp(i,j); end end jml_input = k jml_output=handles.jml_target for i=1:jml_output net(i)=0; end size(handles.w_final) for j=1:1:jml_output
for i=1:1:jml_input x(i)=s_vektor(i); net(j)=net(j)+x(i)*handles.w_final(i,j); end net(j)=net(j)+handles.b_final(j) end for i=1:jml_output if net(i)>=0 net(i)=1 else net(i)=-1 end end jml_pola=size(handles.target,1); cocok=0; axes(handles.axes3); for i=1:jml_pola if handles.target(i,:)==net() imshow(handles.img_original{i}); cocok=1; handles.wav_hasil=strcat('wav',num2str(i),'.wav'); break; end end if cocok==0
h=msgbox('Tidak ada yang cocok','warning'); end
guidata(hObject,handles);
2.1.4 Hasil Eksekusi (RUN) program
Hasil eksekusi program JST Hebb dapat dilihat dalam Gambar 1.4.
Cara kerja program :
- Buka file citra atau gambar dengan menekan tombol
open
pada panel training
- Klik tombol Start Training, setelah menunggu beberapa saat sistem akan
menampilkan bobot (w) dan bias (b) hasil pelatihan pada list box
- Buka file citra atau gambar dengan menekan tombol open pada panel testing
- Klik tombol Start Testing, selanjutnya akan ditampilkan citra hasil testing yang
cocok dengan citra yang diuji.
3. Latihan
1. Buatlah percobaan dengan menggunakan program aplikasi JST Hebb model 2
dengan 5 buah citra pola huruf untuk proses pelatihan. Selanjutnya ujilah atau
testing sistem dengan citra huruf yang cacat atau mengandung noise.
2. Buatlah percobaan dengan memakai program aplikasi JST Hebb model 2 dengan
5 buah citra wajah untuk proses pelatihan atau training. Kemudian testing system
dengan citra wajah cacat atau mengandung noise
JST Perceptron
2.1.Rancangan Graphical User Interface (GUI)
1
2
1
1
2.2 Daftar Komponen
No
Komponen
Properti
1
Panel
Title
Training
2
Axes
Tag
axes1
3
Axes
Tag
axes2
4
Axes
Tag
axes3
5
Push button
String
open
Tag
image1_pushbutton
6
Push button
String
<
Tag
before_pushbutton
7
Push button
String
>
Tag
next_pushbutton
8
Push button
String
Start Training
Tag
start_trainning_pushbutton
9
Push button
String
open
10
Static text1
String
Alpha
11
Static text2
String
Tetha
12
Edit text1
String
kosong
Tag
alpha_edit
13
Edit text2
String
kosong
Tag
tetha_edit
14
Push button
String
Open testing image
Tag
image_testing_pushbutton
10
Push button
String
Start Testing
2.3. Kode Program (source code)
2.3.1 Function
image1_pushbutton_Callback
current_dir=pwd; %getting current directory
handles.img_dir=uigetdir(current_dir,'Select directory'); %Selecting directory %where image saved
%Reading wav files at one folder if exist(handles.img_dir)
cd(handles.img_dir); %change directory D = dir('*.jpg'); %list all wav-file in directory
handles.img_original = cell(1,numel(D));%create 1 X numel(D) cell array of empty matrices
% numel(D)=number of element in directory D for i = 1:numel(D)
[handles.img_original{i},handles.fs{i}] = imread(D(i).name); %save into array 'img_original' end axes(handles.axes1); for i=1:numel(D) imshow(handles.img_original{i}); end handles.number_of_image=numel(D); handles.number_of_max=numel(D); else
h=msgbox('File not found', 'Warning','error'); end
cd(current_dir);%return into current directory
guidata(hObject,handles);
2.3.2 Function
before_pushbutton_Callback
axes(handles.axes1); % will display on axes1 i=handles.number_of_image; if i==1 % before_pushbutton.Enable='off'; imshow(handles.img_original{1}); %handles.number_of_img=1; else imshow(handles.img_original{i});
No
Komponen
Properti
12
Static text3
String
Weight (w) dan Bias (b)
13
List box
String
kosong
Tag
show_listbox
14
Panel
Title
Testing
25
Static text4
String
Hasil Testing
handles.number_of_image = handles.number_of_image-1; end
guidata(hObject,handles);
2.3.3 Function
next_pushbutton_Callback
function next_pushbutton_Callback(hObject, eventdata, handles) axes(handles.axes1); % will display on axes1
i=handles.number_of_image; if i == handles.number_of_max imshow(handles.img_original{i}); else imshow(handles.img_original{i}); handles.number_of_image = handles.number_of_image+1; end guidata(hObject,handles);
2.3.4 Function
start_trainning_pushbutton_Callback
num_file=size(handles.img_original,2); %number of files for i=1:1:num_file s(i,:,:)=rgb2gray(handles.img_original{i}); end jml_citra=size(s,1); jml_baris=size(s,2) jml_kolom=size(s,3)
%ubah citra asli bw menjadi bipolar[1,-1] for k=1:1:jml_citra for i=1:1:jml_baris for j=1:1:jml_kolom if s(k,i,j)>200 %putih s_temp(k,i,j)=-1; else %hitam s_temp(k,i,j)=1; end end end end
%ubah citra 'source' format matrik baris kolom(i,j) jadi format baris(vektor) for m=1:1:jml_citra k=0; for i=1:1:jml_baris for j=1:1:jml_kolom k=k+1; s(m,k)=s_temp(m,i,j); end end end jml_input=k
%tentukan matrik target
handles.jml_target = 3; % 2^handles.jml_target jml_digit=handles.jml_target;
m=0;
i=2^handles.jml_target-1; for k=1:num_file
x=de2bi(i,jml_digit); %desimal to biner, tampilkan sebanyak 'jumlah digit' handles.target(k,:)=x;
i=i-1; end
%ubah target menjadi bipolar for k=1:num_file for i=1:jml_digit if handles.target(k,i)==0 handles.target(k,i)=1; else handles.target(k,i)=-1; end end end
alpha=str2num(get(handles.alpha_edit,'String')); %learning rate tetha=str2num(get(handles.tetha_edit,'String')); %threshold %inisialisasi bobot (w) dan bias (b)
jml_pola=size(s,1) %jml_input = size(s,2)
jml_output=handles.jml_target; %inisialisasi botot w dan bias b for j=1:1:jml_output for i=1:1:jml_input w(i,j)=0; end end for j=1:1:jml_output b(j)=0; end berhenti = false; jml_iterasi = 0; while berhenti==false jml_iterasi=jml_iterasi+1; berhenti=true; for n=1:1:jml_pola for i=1:1:jml_input x(i) = s(n,i); %x(i) = s(i) end %t(n)=s(n,jml_input+1); %target %y(n,j)=handles.target(n,j); % y1 for j=1:1:jml_output %t(n,j)=s(n,jml_input+j); %target t % t(n,2)=s(n,jml_input+2); %target t t(n,j)=handles.target(n,j); % y1 % y(n,2)=t(n,2); % y2 end % sigma=0; for j=1:1:jml_output sigma=0; for i=1:1:jml_input sigma=sigma+x(i)*w(i,j); end y_in(j)=b(j)+sigma; if y_in(j)>tetha y(j)=1; end
if y_in(j)>=-tetha && y_in(j)<=tetha y(j)=0; end if y_in(j)<-tetha y(j)=-1; end
%jika output(y) tidak sesuai target(t) maka perbaiki %bobot w dan bias b
if y(j) ~= t(n,j) for j=1:1:jml_output for i=1:1:jml_input w(i,j)=w(i,j)+alpha*t(n,j)*x(i); handles.w_final(i,j)=w(i,j); end b(j)=b(j)+alpha*t(n,j); handles.b_final(j)=b(j); berhenti=false; end end end end end
%%tampilkan bobot dan bias hasil pelatihan dalam command window editor for j=1:1:jml_output for i=1:1:jml_input disp(strcat('w',num2str(i),num2str(j),' = ',num2str(w(i,j)))); end disp(strcat('b = ',num2str(b(j)))); end
for n=1:1:jml_input %index dari array bobot w i(n)=n;
end
%Tampilkan bobot dalam list box n=1;
for i=1:1:jml_input %index dari array bobot w for j=1:1:jml_output
k(n)=str2num(strcat(num2str(i),num2str(j))); w_vek(n)=w(i,j); %ubah w jadi vektor w_vek n=n+1;
end end
set(handles.show_listbox,'String',strcat('w',num2str(k'),' = ',num2str(w_vek'))); %tampilkan bobot bj, sbg elemen terakhir listbox
for j=1:1:jml_output bobot=strcat('b',num2str(j),' = ',num2str(b(j))); list_box_old=cellstr(get(handles.show_listbox,'String')); list_box_new= [list_box_old;{bobot}]; set(handles.show_listbox,'String',list_box_new) ; end
j_iterasi=strcat('jml iterasi = ',num2str(jml_iterasi)); %tampilkan jumlah iterasi sbg elemen terakhir listbox list_box_old=cellstr(get(handles.show_listbox,'String')); list_box_new= [list_box_old;{j_iterasi}];
set(handles.show_listbox,'String',list_box_new) ; guidata(hObject,handles);
2.3.5 Function
image_testing_pushbutton_Callback
function image_testing_pushbutton_Callback(hObject, eventdata, handles) [filename,pathname]=uigetfile('*.jpg;*.bmp;*.png','Select an Image File');
handles.image_file = strcat(pathname,filename); %"handles.image_file" var image_file %di set agar bisa diakses dari function
%yang lain
if exist(handles.image_file) % check if image exists
handles.im_testing=imread(handles.image_file); % read in the image axes(handles.axes2); % will display on axes1
imshow(handles.im_testing); else % if image doesn t exist
imshow('file_not_found.jpg') % Display the Error image end
guidata(hObject,handles);
2.3.6 Function
start_testing_pushbutton_Callback
function start_testing_pushbutton_Callback(hObject, eventdata, handles) s=rgb2gray(handles.im_testing)
%ubah data menjadi bipolar[1,-1] jml_baris=size(s,1); jml_kolom=size(s,2); for i=1:1:jml_baris for j=1:1:jml_kolom if s(i,j)>=200 %putih s_temp(i,j)=-1; else %hitam s_temp(i,j)=1; end end end
%ubah matrik citra 2 dimensi s_temp jadi vektor 1 dimensi s k=0; for i=1:1:jml_baris for j=1:1:jml_kolom k=k+1; s_vektor(k)=s_temp(i,j); end end jml_input = k jml_output=handles.jml_target for i=1:jml_output net(i)=0; end size(handles.w_final) for j=1:1:jml_output for i=1:1:jml_input x(i)=s_vektor(i); net(j)=net(j)+x(i)*handles.w_final(i,j); end net(j)=net(j)+handles.b_final(j) end for i=1:jml_output if net(i)>=0 net(i)=1 else
net(i)=-1 end end jml_pola=size(handles.target,1); cocok=0; axes(handles.axes3); for i=1:jml_pola if handles.target(i,:)==net() imshow(handles.img_original{i}); cocok=1; handles.wav_hasil=strcat('wav',num2str(i),'.wav'); break; end end if cocok==0
h=msgbox('Tidak ada yang cocok','warning'); end
guidata(hObject,handles);
2.4 Hasil Eksekusi (RUN) program
Hasil eksekusi program JST Perceptron dapat dilihat dalam Gambar 2.2.
Cara kerja program :
- Buka file citra atau gambar dengan menekan tombol
open
pada panel training
- Masukkan nilai alpha (misal : 0.7) dan nilai tetha (misal : 0.3). Klik tombol
Start Training, setelah menunggu beberapa saat sistem akan menampilkan
bobot (w) dan bias (b) hasil pelatihan pada list box
- Buka file citra atau gambar dengan menekan tombol open pada panel testing
- Klik tombol Start Testing, selanjutnya akan ditampilkan citra hasil testing yang
cocok dengan citra yang diuji.
2.5 Latihan
1. Buatlah percobaan dengan menggunakan program aplikasi JST Perceptron
dengan 5 buah citra pola huruf untuk proses pelatihan. Selanjutnya ujilah atau
testing sistem dengan citra huruf yang cacat atau mengandung noise.
2. Buatlah percobaan dengan memakai program aplikasi JST Perceptron dengan 5
buah citra sidik jari untuk proses pelatihan atau training. Kemudian testing
system dengan citra wajah cacat atau mengandung noise
JST Heteroassociative Memory (HM)
3.1.Rancangan Graphical User Interface (GUI)
3.2 Daftar Komponen
1
3
1
1
2.3. Kode Program (source code)
2.3.1 Function
image1_pushbutton_Callback
current_dir=pwd; %getting current directory
handles.image_dir=uigetdir(current_dir,'Select directory'); %Selecting directory %where image saved
No
Komponen
Properti
1
Panel
Title
Training
2
Axes
Tag
axes1
3
Axes
Tag
axes2
4
Push button
String
open
Tag
image1_pushbutton
5
Push button
String
<
Tag
before_pushbutton
6
Push button
String
>
Tag
next_pushbutton
7
Push button
String
<
Tag
before2_pushbutton
8
Push button
String
>
Tag
next2_pushbutton
9
Push button
String
Start Training
Tag
start_trainning_pushbutton
10
Push button
String
open
11
Push button
String
Open testing image
Tag
image_testing_pushbutton
12
Push button
String
Start Testing
Tag
start_testing_pushbutton
No
Komponen
Properti
13
Static text3
String
Weight (w) dan Bias (b)
14
List box
String
kosong
Tag
show_listbox
15
Panel
Title
Testing
16
Static text4
String
Hasil Testing
%Reading multiple image files at one folder if exist(handles.image_dir)
cd(handles.image_dir); %change directory D = dir('*.jpg');
handles.im_original = cell(1,numel(D));% number element for i = 1:numel(D)
handles.im_original{i} = imread(D(i).name); %save image data into array 'im_original' end axes(handles.axes1); %imshow(imcell{1}); for i=1:numel(D) imshow(handles.im_original{i}); end handles.number_of_image=numel(D); handles.number_of_max=numel(D); else
h=msgbox('file not found', 'Warning','error'); end
cd(current_dir);%return into current directory
guidata(hObject,handles);
2.3.2 Function
before_pushbutton_Callback
i=handles.number_of_image; if i==1 imshow(handles.im_original{1}); %handles.number_of_img=1; else imshow(handles.im_original{i}); handles.number_of_image = handles.number_of_image-1; end guidata(hObject,handles);
2.3.3 Function
next_pushbutton_Callback
function next_pushbutton_Callback(hObject, eventdata, handles) i=handles.number_of_image; if i == handles.number_of_max imshow(handles.im_original{i}); %handles.number_of_img=1; else imshow(handles.im_original{i}); handles.number_of_image = handles.number_of_image+1; end guidata(hObject,handles);
2.3.1 Function
image1_target_pushbutton_Callback
current_dir=pwd; %getting current directory
handles.image_dir=uigetdir(current_dir,'Select directory'); %Selecting directory %where image saved
%Reading multiple image files at one folder if exist(handles.image_dir)
cd(handles.image_dir); %change directory D = dir('*.jpg');
handles.im_original = cell(1,numel(D));% number element for i = 1:numel(D)
end axes(handles.axes2); %imshow(imcell{1}); for i=1:numel(D) imshow(handles.im_original{i}); end handles.number_of_image=numel(D); handles.number_of_max=numel(D); else
h=msgbox('file not found', 'Warning','error'); end
cd(current_dir);%return into current directory guidata(hObject,handles);
2.3.4 Function
before2_pushbutton_Callback
i=handles.number_of_image_target; if i==1 imshow(handles.im_original_target{1}); %handles.number_of_img=1; else imshow(handles.im_original_target{i}); handles.number_of_image_target = handles.number_of_image_target-1; end guidata(hObject,handles);
2.3.5 Function
next2_pushbutton_Callback
function next_pushbutton_Callback(hObject, eventdata, handles) i=handles.number_of_image_target; if i == handles.number_of_max_target imshow(handles.im_original_target{i}); %handles.number_of_img=1; else imshow(handles.im_original_target{i}); handles.number_of_image_target = handles.number_of_image_target+1; end guidata(hObject,handles);
2.3.4 Function
start_trainning_pushbutton_Callback
num_im=size(handles.im_original,2); %number of images for i=1:1:num_im s(i,:,:)=im2bw(handles.im_original{i}); end %s(1,:,:) %size(s) for i=1:1:num_im s_target(i,:,:)=im2bw(handles.im_original_target{i}); end %s_target(1,:,:) %size(s_target) jml_citra=size(s,1); jml_baris=size(s,2); jml_kolom=size(s,3);
%ubah citra asli bw menjadi bipolar[1,-1] for k=1:1:jml_citra for i=1:1:jml_baris for j=1:1:jml_kolom if s(k,i,j)>0 %putih s_temp(k,i,j)=-1; else %hitam s_temp(k,i,j)=1; end end end end
%ubah citra "target" bw menjadi bipolar[1,-1] handles.jml_citra_target=size(s_target,1); handles.jml_baris_target=size(s_target,2); handles.jml_kolom_target=size(s_target,3); for k=1:1:handles.jml_citra_target for i=1:1:handles.jml_baris_target for j=1:1:handles.jml_kolom_target if s_target(k,i,j)> 0 %putih s_target_temp(k,i,j)=-1; else %hitam s_target_temp(k,i,j)=1; end handles.s_target_bipolar(k,i,j)=s_target_temp(k,i,j); end end end %handles.s1_target_bipolar
%ubah citra 'source' format matrik baris kolom(i,j) jadi format baris %citra 1 for m=1:1:jml_citra k=0; for i=1:1:jml_baris for j=1:1:jml_kolom k=k+1; source(m,k)=s_temp(m,i,j); end end end
%ubah citra 'target' format matrik baris kolom(i,j) jadi format baris %citra target 1 for k=1:1:handles.jml_citra_target m=0; for i=1:1:handles.jml_baris_target for j=1:1:handles.jml_kolom_target m=m+1; target(k,m)=s_target_temp(k,i,j); end end end
jml_pola=size(source,1); jml_input = size(source,2); jml_output=size(target,2); %handles.jml_baris_target*handles.jml_kolom_target; handles.w=0; for i=1:1:jml_pola handles.w= handles.w+source(i,:)'*target(i,:); end
%%tampilkan bobot dan bias hasil pelatihan dalam command window %for j=1:1:jml_output % for i=1:1:jml_input % disp(strcat('w',num2str(i),num2str(j),' = ',num2str(handles.w(i,j)))); % end %end
%Tampilkan bobot dalam list box %n=0;
%for j=1:1:jml_output %index dari bobot w % for i=1:1:jml_input % n=n+1; % in(n)=i; % jn(n)=j; % wn(n)=handles.w(i,j); % end %end %set(handles.show_listbox,'String',strcat('w',num2str(in'),num2str(jn'),' = ',num2str(wn'))); guidata(hObject,handles);
2.3.5 Function
image_testing_pushbutton_Callback
function image_testing_pushbutton_Callback(hObject, eventdata, handles) [filename,pathname]=uigetfile('*.jpg;*.bmp;*.png','Select an Image File');
handles.image_file = strcat(pathname,filename); %"handles.image_file" var image_file %di set agar bisa diakses dari function
%yang lain
if exist(handles.image_file) % check if image exists
handles.im_testing=imread(handles.image_file); % read in the image axes(handles.axes3); % will display on axes1
imshow(handles.im_testing); else % if image doesn_t exist
imshow('file_not_found.jpg') % Display the _Error image_ end
guidata(hObject,handles);
2.3.6 Function
start_testing_pushbutton_Callback
function start_testing_pushbutton_Callback(hObject, eventdata, handles) s=im2bw(handles.im_testing);
%ubah data menjadi bipolar[1,-1] jml_baris=size(s,1); jml_kolom=size(s,2); for i=1:1:jml_baris for j=1:1:jml_kolom if s(i,j)>0 %putih s_temp(i,j)=-1; else %hitam s_temp(i,j)=1; end
end end s_temp
%ubah matrik citra baris-kolom s_temp jadi matrik baris k=0; for i=1:1:jml_baris for j=1:1:jml_kolom k=k+1; s_vektor(k)=s_temp(i,j); end end jml_input = k; jml_output=handles.jml_baris_target*handles.jml_kolom_target; y_temp=s_vektor*handles.w; for j=1:1:jml_output if y_temp(j)>0 y(j)=1; else if y_temp(j)<=0 y(j)=-1; else if y_temp(j)==0 y(j)=0; end end end end
%bandingkan output dengan target axes(handles.axes4); for k=1:handles.jml_citra_target if y==handles.s_target_bipolar(k,:); imshow(handles.im_original{k}); break; end end
2.4 Hasil Eksekusi (RUN) program
Cara kerja program :
- Buka file citra atau gambar pelatihan (source image(s)) dengan menekan
tombol
open
pada panel training
- Buka file citra atau gambar (target image(t)) dengan menekan tombol
open
pada panel training
- Lakukan proses training dengan menekan tombol Start Training
- Buka file citra atau gambar testing dengan menekan tombol open pada panel
testing
- Klik tombol Start Testing, selanjutnya akan ditampilkan citra hasil testing yang
cocok dengan citra yang diuji.
2.5 Latihan
1. Buatlah percobaan dengan menggunakan program aplikasi JST HM dengan 5
buah citra wajah untuk proses pelatihan. Selanjutnya ujilah atau testing sistem
dengan citra huruf yang cacat atau mengandung noise.
2. Buatlah percobaan dengan memakai program aplikasi JST HM dengan 5 buah
citra sidik jari untuk proses pelatihan atau training. Kemudian testing sistem
dengan citra sidik jari cacat atau mengandung noise
JST Back Propagation (BP)
4.1.Rancangan Graphical User Interface (GUI)
4.2 Daftar Komponen
1
4
1
1
4.3. Kode Program (source code)
No
Komponen
Properti
1
Panel
Title
Training
2
listbox
String
Tag
data_trainning_listbox
3
Push button
String
open data trainning
Tag
data_trainning_pushbutton
4
listbox
String
Tag
data_wb_listbox
5
Push button
String
open weight - bias
Tag
data_wb_pushbutton
6
Static text
String
Jumlah hidden unit
7
Edit text
String
tag
jml_hidden_edit
7
Static text
String
Learning Rate
8
Edit text
String
tag
learning_rate_edit
9
Static text
String
weight(w)-bias(b) after trainning
10
listbox
String
Tag
wb_result_listbox
11
Push button
String
Start Training
Tag
start_training_pushbutton
12
Panel
Title
Testing
13
listbox
String
Tag
data_testing_listbox
14
Push button
String
open data testing
Tag
data_testing_pushbutton
15
listbox
String
Tag
result_listbox
16
Static text
String
Hasil Testing
17
Push button
String
Start Testing
Tag
start_testing_pushbutton
16
Static text
String
Physics, Unud, Bali
4.3.1 Function
data_trainning_pushbutton_Callback
[filename,handles.pathname]=uigetfile('*.xls;*.xlsx','Select data trainning'); handles.data_trainning_file = strcat(handles.pathname,filename);
if exist(handles.data_trainning_file) % check if files exists
handles.data_trainning=xlsread(handles.data_trainning_file); % read data trainning in 'excels' file
end
set(handles.data_trainning_listbox,'String',num2str(handles.data_trainning)); guidata(hObject,handles);
4.3.2 Function
data_wb_pushbutton_Callback
[filename,pathname]=uigetfile('*.xls;*.xlsx','Select data trainning'); handles.wb_file = strcat(pathname,filename);
if exist(handles.wb_file) % check if files exists
handles.wb=xlsread(handles.wb_file); % read data trainning in 'excels' file end
set(handles.data_wb_listbox,'String',num2str(handles.wb)); guidata(hObject,handles);
4.3.3 Function
start_training_pushbutton_Callback
jml_baris=size(handles.data_trainning,1); jml_kolom=size(handles.data_trainning,2); jml_pola=size(handles.data_trainning,1); jml_input=size(handles.data_trainning,2)-1; jml_output=size(handles.data_trainning,2)-jml_input; jml_hid=str2num(get(handles.jml_hidden_edit,'String')); alpa=str2num(get(handles.learning_rate_edit,'String'));
%reading data source for n=1:1:jml_pola for i=1:1:jml_input s(n,i)= handles.data_trainning(n,i); end end s
%reading data target for n=1:1:jml_pola for i=1:1:jml_output t(n,i)=handles.data_trainning(n,jml_input+i); end end t jml_input jml_hid size(handles.wb) %handles.wb(2,4)
%reading data weight and bias
%reading data weight hidden layer for i=1:1:jml_input for j=1:1:jml_hid v(i,j)=handles.wb(i,j); end end v
%reading data bias hidden layer for i=1:1:jml_hid
v0(i)=handles.wb(jml_input+1,i); end
v0
%reading data weight output layer for i=1:1:jml_hid for j=1:1:jml_output w(i,j)=handles.wb(jml_input+1+i,j); end end w
%reading data bias output layer for i=1:1:jml_output w0(i)=handles.wb(jml_input+1+jml_hid+1,i); end w0 eps=0.05; tot_err=0; jml_iterasi=0; stop=false; %********Mulai Pelatihan********** while stop==false %%tot_err=0; for n=1:1:jml_pola for j=1:1:jml_hid tot_j=0; for i=1:1:jml_input x(i)=s(n,i); tot_j=tot_j+x(i)*v(i,j); end z_in(j)=v0(j)+tot_j;
%%z[j]=1/(1+exp(-(z_in[j]))); %FUNGSI BINER SIGMOID z(j)=(2/(1+exp(-(z_in(j)))))-1; %FUNGSI BIPOLAR SIGMOID end for k=1:1:jml_output tot_k=0; for j=1:1:jml_hid tot_k=tot_k+z(j)*w(j,k); end y_in(k)=w0(k)+tot_k;
%y[k]=1/(1+exp(-y_in[k])); %FUNGSI BINER SIGMOID y(k)=(2/(1+exp(-y_in(k))))-1; %FUNGSI BIPOLAR SIGMOID end %BACKPROPAGATION %tot_err=0; for k=1:1:jml_output
%fx=1/(1+exp(-y_in[k])); %biner sigmoid %diff=fx*(1-fx);//turunan pertama
fx=(2/(1+exp(-y_in(k))))-1; %Bipolar sigmoid diff=0.5*(1+fx)*(1-fx); %turunan pertama t1(k)=t(n,k); %target
tot_err=tot_err+(t1(k)-y(k))^2; %total error kuadrat del_k(k)=(t1(k)-y(k))*diff; %error
for j=1:1:jml_hid
delta_w(j,k)=alpa*del_k(k)*z(j); %delta bobot pada unit output end
delta_w0(k)=alpa*del_k(k); %delta bias pd unit output end for j=1:1:jml_hid tot_e_k=0; for k=1:1:jml_output tot_e_k=tot_e_k+del_k(k)*w(j,k); end del_in(j)=tot_e_k;
%fx=1/(1+exp(-z_in(j))); %biner sigmoid %diff=fx*(1-fx); fx=(2/(1+exp(-z_in(j))))-1; diff=0.5*(1+fx)*(1-fx); del_j(j)=del_in(j)*diff; for i=1:1:jml_input x(i)=s(n,i);
delta_v(i,j)=alpa*del_j(j)*x(i); %delta bobot pd unit hidden end
delta_v0(j)=alpa*del_j(j); %delta bias pd unit hidden end
%UBAH BOBOT DAN BIAS
%Ubah bobot unit output for j=1:1:jml_hid
for k=1:1:jml_output
w(j,k)=w(j,k)+delta_w(j,k); end
end
%ubah bias unit output for k=1:1:jml_output
w0(k)=w0(k)+delta_w0(k); end
%ubah bobot unit hidden for i=1:1:jml_input for j=1:1:jml_hid
v(i,j)=v(i,j)+delta_v(i,j); end
end
%ubah bias unit hidden for j=1:1:jml_hid v0(j)=v0(j)+delta_v0(j); end end %for n if tot_err>eps %continue tot_err=0; jml_iterasi=jml_iterasi+1 stop=false; else %stop stop=true; end
end %while stop
%saving trainning result into excels file
v(jml_input+1,:)=v0; %bias unit hiden
for i=1:1:jml_hid
v(jml_input+1+i,1)=w(i); %bobot unit output end
for i=1:1:jml_output
v(jml_input+1+jml_hid+i,1)=w0(i); %bias unit output end
%simpan bobot w dan bias b dalam excel file if exist(strcat(handles.pathname,'bobot_hasil_backprop.xls')); delete (strcat(handles.pathname,'bobot_hasil_backprop.xls')); xlswrite(strcat(handles.pathname,'bobot_hasil_backprop.xls'),v); else xlswrite(strcat(handles.pathname,'bobot_hasil_backprop.xls'),v); end set(handles.wb_result_listbox,'String',num2str(v));
%%tampilkan bobot dan bias hasil pelatihan dalam comman window %for j=1:1:jml_output % for i=1:1:jml_input % disp(strcat('w',num2str(i),num2str(j),' = ',num2str(handles.w(i,j)))); % end %end
%Tampilkan bobot dalam list box %n=0;
%for j=1:1:jml_output %index dari bobot w % for i=1:1:jml_input % n=n+1; % in(n)=i; % jn(n)=j; % wn(n)=handles.w(i,j); % end %end %set(handles.wb_result_listbox,'String',strcat('w',num2str(in'),num2str(jn'),' = ',num2str(wn'))); guidata(hObject,handles);
4.3.4 Function
data_testing_pushbutton_Callback
[filename,pathname]=uigetfile('*.xls;*.xlsx','Select data trainning'); handles.data_testing_file = strcat(pathname,filename);
if exist(handles.data_testing_file) % check if files exists
handles.data_testing=xlsread(handles.data_testing_file); % read data trainning in 'excels' file
end
set(handles.data_testing_listbox,'String',num2str(handles.data_testing')); guidata(hObject,handles);
4.3.5 Function
start_testing_pushbutton_Callback
jml_input=size(handles.data_trainning,2)-1; jml_output=size(handles.data_trainning,2)-jml_input; jml_hid=str2num(get(handles.jml_hidden_edit,'String')); alpa=str2num(get(handles.learning_rate_edit,'String'));
%reading data source for i=1:1:jml_input
x(i)= handles.data_testing(1,i); end
%read weight and bias of trainning
wb_testing=xlsread(strcat(handles.pathname,'bobot_hasil_backprop.xls'));
%reading data weight of hidden layer , v for i=1:1:jml_input for j=1:1:jml_hid v(i,j)=wb_testing(i,j); end end v
%reading data bias hidden layer, v0 for i=1:1:jml_hid
v0(i)=wb_testing(jml_input+1,i); end
v0
%reading data weight output layer, w for i=1:1:jml_hid for j=1:1:jml_output w(i,j)=wb_testing(jml_input+1+i,j); end end w
%reading data bias output layer , w0 for i=1:1:jml_output w0(i)=wb_testing(jml_input+1+jml_hid+1,i); end w0 %proses Testing for j=1:1:jml_hid tot=0; for i=1:1:jml_input tot=tot+x(i)*v(i,j); end z_in(j)=v0(j)+tot;
%z(j)=1/(1+exp(-z_in(j))); %biner sigmoid z(j)=(2/(1+exp(-z_in(j))))-1; %bipolar sigmoid end for k=1:1:jml_output tot=0; for j=1:1:jml_hid tot=tot+z(j)*w(j,k); end y_in(k)=w0(k)+tot; %y[k]=1/(1+exp(-y_in[k])); y(k)=(2/(1+exp(-y_in(k))))-1; end set(handles.result_listbox,'String',num2str(y')); %set(handles.wb_result_listbox,'String',list_box_new) ; y