isi

12
1. Tujuan: a. Mempelajari mengenai JST Hebb. b. Mengetahui dan membuktikan ukuran gambar yang dapat diproses oleh JST Hebb. c. Mengerti mengenai proses training JST Heb menggunakan gambar. 2. Rumusan Masalah: 1. Berapa ukuran (pixel) gambar yang digunakan pada JST Hebb? 2. Apakah ukuran gambar mempengaruhi hasil testing JST Hebb? 3. Berapa lama hasil testing JST Hebb keluar? 3. Rancangan/ desain GUI Gambar 1.1 Desain GUI – Jst Hebb Trainning Image GUI

Upload: husnul-hatimah

Post on 03-Dec-2015

8 views

Category:

Documents


0 download

DESCRIPTION

Contoh Tugas Pelatihan/Proses Belajar Jaringan Syaraf Tiruan Hebb.

TRANSCRIPT

Page 1: Isi

1. Tujuan:

a. Mempelajari mengenai JST Hebb.

b. Mengetahui dan membuktikan ukuran gambar yang dapat diproses oleh JST Hebb.

c. Mengerti mengenai proses training JST Heb menggunakan gambar.

2. Rumusan Masalah:

1. Berapa ukuran (pixel) gambar yang digunakan pada JST Hebb?

2. Apakah ukuran gambar mempengaruhi hasil testing JST Hebb?

3. Berapa lama hasil testing JST Hebb keluar?

3. Rancangan/ desain GUI

Gambar 1.1 Desain GUI – Jst Hebb Trainning Image GUI

4. Kode Program (source code)

function negative_pushbutton_Callback(hObject, eventdata, handles)% hObject handle to negative_pushbutton (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA) if exist(handles.image_file) % check if image exists axes(handles.axes1);

Page 2: Isi

imshow(imcomplement(handles.im_original));else % if image doesn_t exist imshow('file_not_found.jpg') % Display the _Error image_end % --- Executes during object creation, after setting all properties.function file_name_edit_CreateFcn(hObject, eventdata, handles)% hObject handle to file_name_edit (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows.% See ISPC and COMPUTER.if ispc set(hObject,'BackgroundColor','white');else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));end % --- Executes on button press in image1_pushbutton.function image1_pushbutton_Callback(hObject, eventdata, handles)% hObject handle to image1_pushbutton (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)[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 lainif 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_endguidata(hObject,handles); % --- Executes on button press in image2_pushbutton.function image2_pushbutton_Callback(hObject, eventdata, handles)% hObject handle to image2_pushbutton (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA) [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 lainif exist(handles.image_file) % check if image exists

Page 3: Isi

handles.im_original2=imread(handles.image_file); % read in the image axes(handles.axes2); % will display on axes1 imshow(handles.im_original2);else % if image doesn_t exist imshow('file_not_found.jpg') % Display the _Error imageendguidata(hObject,handles); % --- Executes on button press in image_testing_pushbutton.function image_testing_pushbutton_Callback(hObject, eventdata, handles)% hObject handle to image_testing_pushbutton (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)[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 lainif 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_endguidata(hObject,handles); % --- Executes on button press in start_training_pushbutton.function start_training_pushbutton_Callback(hObject, eventdata, handles)% hObject handle to start_training_pushbutton (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)s1=rgb2gray(handles.im_original1);s2=rgb2gray(handles.im_original2); %ubah data menjadi bipolar[1,-1]jml_baris=size(s1,1);jml_kolom=size(s1,2);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 endend 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;

Page 4: Isi

end endend %jml_pola= 2; % 2 citrak=0;for i=1:1:jml_baris for j=1:1:jml_kolom k=k+1; s(1,k)=s1_temp(i,j); endendt1=1; %target untuk citra 1 simpan sbg kolom %akhir dalam array s s(1,k+1)=t1;k=0;for i=1:1:jml_baris for j=1:1:jml_kolom k=k+1; s(2,k)=s2_temp(i,j); endendt2=-1; %target untuk citra 2 s(2,k+1) = t2; %inisialisasi bobot (w) dan bias (b)jml_pola=size(s,1);jml_input = size(s,2)-1; for i=1:1:jml_input w(i)=0;endb=0; 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)=t(n); %s(n,jml_input+1); %% y = target %perbaiki bobot dan bias for i=1:1:jml_input w(i) = w(i) + x(i)*y(n); % w_baru =w_lama+x(i)* y handles.w_final(i)=w(i); end b=b+y(n); %b_baru= b_lama + y handles.b_final=b;end %%tampilkan bobot dan bias hasil pelatihanfor i=1:1:jml_input disp(strcat('w',num2str(i),' = ',num2str(w(i))));enddisp(strcat('b = ',num2str(b))); %Tampilkan bobot dalam list box

Page 5: Isi

for n=1:1:jml_input %index dari array bobot w i(n)=n;endset(handles.show_listbox,'String',strcat('w',num2str(i'),' = ',num2str(w'))); bobot=strcat('b = ',num2str(b));%tampilkan bobot sbg elemen terakhir listboxlist_box_old=cellstr(get(handles.show_listbox,'String'));list_box_new= [list_box_old;{bobot}];set(handles.show_listbox,'String',list_box_new) ; guidata(hObject,handles); % --- Executes on button press in start_testing_pushbutton.function start_testing_pushbutton_Callback(hObject, eventdata, handles)% hObject handle to start_testing_pushbutton (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)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 endend %ubah matrik citra 2 dimensi s_temp jadi vektor 1 dimensi sk=0;for i=1:1:jml_baris for j=1:1:jml_kolom k=k+1; s_vektor(k)=s_temp(i,j); endendjml_input = k;net=0;for i=1:1:jml_input x(i)=s_vektor(i); net=net+x(i)*handles.w_final(i);endnet=net+handles.b_finalaxes(handles.axes4);if net>=0 f=1 imshow(handles.im_original1);else f=-1 imshow(handles.im_original2); end

Page 6: Isi

5. Hasil Eksekusi (RUN) program

Gambar 3.1 Hasil Eksekusi program Jst Hebb Trainning Image GUI

6. Cara kerja program :

6.1 Gambar dan Noise (Testing Image):

a. Gambar yang diuji:

b. Noise (Testing Image):

6.2 Ukuran gambar:a. 100 x 50 pixel:

Page 7: Isi

Gambar 6.2.1 Hasil Trainning Gambar JST Hebb dengan ukuran 100 x 50 pixel

b. 100 x 100 pixel:

Gambar 6.2.2 Hasil Trainning Gambar JST Hebb dengan ukuran 100 x 100 pixel

c. 500 x 100 pixel:

Page 8: Isi

Gambar 6.2.3 Hasil Trainning Gambar JST Hebb dengan ukuran 500 x 100 pixel

d. 900 x 100 pixel:

Gambar 6.2.4 Hasil Trainning Gambar JST Hebb dengan ukuran 900 x 100 pixel

e. 500 x 500 pixel:

Page 9: Isi

Gambar 6.2.5 Hasil Trainning Gambar JST Hebb dengan ukuran 500 x 500 pixel

7. Kesimpulan:Dari percobaan diatas dapat diambil kesimpulan bahwa:1. Membuat gambar untuk JST ukurannya berupa pixel.2. Percobaan yang dilakukan menggunakan beberapa ukuran (pixel) berbeda dan hal itu

tidak mempengaruhi hasil testing.3. Persentase hasil testing adalah 100 % walaupun berbeda ukuran. 4. Semakin besar ukuran (pixel) yang digunakan pada gambar maka hasil testingnya akan

semakin lama keluarnya karena jumlah bobot (w) hasil training adalah perkalian antara ukuran (horizontal x vertical) gambar.

e

b

b