Anda di halaman 1dari 50

1

JARINGAN SARAF TIRUAN UNTUK MENDETEKSI TAHU KUNING MENGGUNAKAN METODE BACKPROPAGATION

Disusun Oleh : SITI KHOIRIYAH 06.2008.1.04523

BIDANG STUDY JARINGAN SARAF TIRUAN JURUSAN TEKNIK INFORMATIKA FAKULTAS TEKNOLOGI INFORMASI INSTITUT TEKNOLOGI ADHI TAMA SURABAYA 2012

I.

Pendahuluan Perkembangan teknologi pangan telah maju seiring dengan perkembangan

teknologi di Indonesia. Berbagai upaya dilakukan oleh produsen pangan untuk meningkatkan mutu produksinya, tidak terkecuali para pengrajin tahu. Sayangnya pengetahuan tentang produk yang bermutu baik masih rendah, sehingga terkadang penyerapan teknologi mereka dilakukan dengan salah kaprah seperti misalnya dalam penggunaan zat pewarna. Disamping itu masyarakat konsumen juga turut mendorong terjadinya kesalahan tersebut. Mereka lebih menyukai produk-produk yang berwarna cerah dibandingkan dengan produk yang berwarna alami. Hal ini disebabkan karena tingkat kesadaran mereka sebagai konsumen masih rendah, sehingga mereka belum mampu membeli produk yang bermutu baik. Dengan menggunakan jaringan saraf tiruan, akan dibuat sebuah program untuk mendeteksi tahu kuning yang menggunakan pewarna alami dan pewarna buatan dengan menggunakan metode backpropagation.

II.

Tujuan

Tujuan dari pembuatan program deteksi tahu kuning adalah sebagai berikut : 1. Membuat program untuk mendeteksi tahu kuning alami dan tahu kuning berpewarna buatan dengan menggunakan jarungan saraf tiruan. 2. Untuk membedakan warna tahu kuning alami dan warna tahu kuning berpewarna buatan.

III. Algoritma Backpropagation Backpropagation merupakan algoritma pembelajaran yang terawasi dan biasanya digunakan oleh perceptron dengan banyak lapisan untuk mengubah bobot-bobot yang terhubung dengan neuron-neuran yang ada pada lapisan tersembunyinya. Algoritma backpropagation menggunakan error output untuk mengubah nilai bobot-bobotnya dalam arah mundur (backward). Untuk mendapatkan error ini, tahap perambatan maju (forward propagation) harus

dikerjakan terlebih dahulu. Pada saat perambatan maju, neuron-neuron diaktifkan dengan menggunakan fungsi aktivasi sigmoid, yaitu:

Algoritma backpropagation: Inisialisasi bobot (ambil bobot awal dengan nilai random yang cukup kecil). Kerjakan langkah-langkah berikut selama kondisi berhenti bernilai FALSE: 1. Untuk tiap-tiap pasangan elemen yang akan dilakukan pembelajaran, kerjakan: Feedforward: a. Tiap-tiap unit input (Xi, i=1,2,3,...,n) menerima sinyal xi dan meneruskan sinyak tersebut ke semua unit pada lapisan yang ada di atasnya (lapisan tersembunyi). b. Tiap-tiap unit tersembunyi (Zi, j=1,2,3,...,p) menjumlahkan sinyal-sinyal input terbobot:

gunakan fungsi aktivasi untuk menghitung sinyal outputnya: zj = f(z_inj) dan kirimkan sinyal tersebut ke semua unit di lapisan atasnya (unit-unit output). c. Tiap-tiap unit output (Yk, k=1,2,3,...,m) menjumlahkan sinyalsinyal input terbobot.

gunakan fungsi aktivasi untuk menghitung sinyal outputnya: yk = f(y_ink) dan kirimkan sinyal tersebut ke semua unit di lapisan atasnya (unit-unit output).

Backpropagation d. Tiap-tiap unit output (Yk, k=1,2,3,...,m) menerima target pola yang berhubungan dengan pola input pembelajaran, hitung informasi errornya:

kemudian hitung koreksi bobot (yang nantinya akan digunakan untuk memperbaiki nilai wjk):

hitung juga koreksi bias (yang nantinya akan digunakan untuk memperbaiki nilai w0k):

kirimkan

ini ke unit-unit yang ada di lapisan bawahnya.

e. Tiap-tiap unit tersembunyi (Zj, j=1,2,3,...,p) menjumlahkan delta inputnya (dari unit-unit yang berada pada lapisan di atasnya):

kalikan nilai ini dengan turunan dari fungsi aktivasinya untuk menghitung informasi error:

kemudian hitung koreksi bobot (yang nantinya akan digunakan untuk memperbaiki nilai vij):

hitung juga koreksi bias (yang nantinya akan digunakan untuk memperbaiki nilai v0j):

f. Tiap-tiap unit output (Yk, k=1,2,3,...,m) memperbaiki bias dan bobotnya (j=0,1,2,...,p): wjk(baru) = wjk(lama) + wjk

Tiap-tiap unit tersembunyi (Zj, j=1,2,3,...,p) memperbaiki bias dan bobotnya (i=0,1,2,...,n): vij(baru) = vij(lama) + 2. Tes kondisi berhenti, vij

IV. Implementasi Pada program jaringan saraf tiruan untuk mendeteksi tahu kuning menggunkan metode backpropagation menggunakan bahasa pemrograman Visual Basic 6.0. berikut adalah source code programnya :
Dim fheight As Integer, step As Integer Dim cmdDialog1() As Double Dim pixels(1 To 100, 1 To 100) As Long Dim Error As Double Dim S_in(), deltaWjk(), S(), deltaVij(), deltaW0(), deltaV0() As Double Dim last_deltaWjk(), last_deltaVij() As Double Dim Errors() As Double Public Function f(ByVal X As Double) As Double f = 1 / (1 + Exp(-X)) End Function Public Function df(ByVal X As Double) As Double df = f(X) * (1 - f(X)) End Function Private Sub Cmd_Gambar0_Click() With CmnDialog(0) .DialogTitle = "gambar input" .CancelError = False .Filter = "Picture File |*.jpg" .ShowOpen File_name = .FileName

Gambar(0).Picture = LoadPicture(File_name) End With End Sub Private Sub Cmd_Gambar4_Click() With CmnDialog(4) .DialogTitle = "gambar input" .CancelError = False .Filter = "Picture File |*.jpg" .ShowOpen File_name = .FileName Gambar(4).Picture = LoadPicture(File_name) End With End Sub Private Sub Cmd_Gambar5_Click() With CmnDialog(5) .DialogTitle = "gambar input" .CancelError = False .Filter = "Picture File |*.jpg" .ShowOpen File_name = .FileName Gambar(5).Picture = LoadPicture(File_name) End With End Sub Private Sub Cmd_Gambar6_Click() With CmnDialog(6) .DialogTitle = "gambar input" .CancelError = False .Filter = "Picture File |*.jpg" .ShowOpen File_name = .FileName Gambar(6).Picture = LoadPicture(File_name)

End With End Sub Private Sub Cmd_Gambar7_Click() With CmnDialog(7) .DialogTitle = "gambar input" .CancelError = False .Filter = "Picture File |*.jpg" .ShowOpen File_name = .FileName Gambar(7).Picture = LoadPicture(File_name) End With End Sub Private Sub Cmd_Gambar1_Click() With CmnDialog(1) .DialogTitle = "gambar input" .CancelError = False .Filter = "Picture File |*.jpg" .ShowOpen File_name = .FileName Gambar(1).Picture = LoadPicture(File_name) End With End Sub Private Sub Cmd_Gambar2_Click() With CmnDialog(2) .DialogTitle = "gambar input" .CancelError = False .Filter = "Picture File |*.jpg" .ShowOpen File_name = .FileName Gambar(2).Picture = LoadPicture(File_name) End With

End Sub Private Sub Cmd_Gambar3_Click() With CmnDialog(3) .DialogTitle = "gambar input" .CancelError = False .Filter = "Picture File |*.jpg" .ShowOpen File_name = .FileName Gambar(3).Picture = LoadPicture(File_name) End With End Sub Private Sub Cmd_Pixel0_Click() Dim GreyTH As Integer Const TresHold = 100 tabel_Input(0).Cols = 16 tabel_Input(0).Rows = 16 '''''''''''''ANGKA BARIS & KOLOM For c = 1 To tabel_Input(0).Cols - 1 For r = 1 To tabel_Input(0).Rows - 1 tabel_Input(0).TextMatrix(r, 0) = r tabel_Input(0).TextMatrix(0, c) = c Next r Next c ''''''''''''''NGAMBIL PIXEL For X = 1 To tabel_Input(0).Rows - 1 For Y = 1 To tabel_Input(0).Cols - 1 pixels(X, Y) = Gambar(0).Point(Y, X) Next Y Next X

''''''''''''''NULIS NILAI For X = 1 To tabel_Input(0).Rows - 1 For Y = 1 To tabel_Input(0).Cols - 1 r = pixels(X, Y) And &HFF g = (pixels(X, Y) And &HFF00 / &H100) Mod &H100 b = (pixels(X, Y) And &HFF0000 / &H10000) Mod &H100 Grey = (r + g + b) / 3 tabel_Input(0).TextMatrix(X, Y) = Grey Next Y Next X ''''''''''''MBUAT MATRIK JADI SATU BARIS tabel_Normalisasi(0).Cols = (tabel_Input(0).Cols - 1) * (tabel_Input(0).Rows - 1) For c = 1 To Val(tabel_Normalisasi(0).Cols) tabel_Normalisasi(0).TextMatrix(0, c - 1) = c Next c ''''''''''''NILAI JADI SATU BARIS For X = 1 To tabel_Input(0).Rows - 1 For Y = 1 To tabel_Input(0).Cols - 1 c = 15 * (X - 1) + Y tabel_Normalisasi(0).TextMatrix(1, c - 1) = Val(tabel_Input(0).TextMatrix(X, Y)) Next Y Next X ''''''''''''NORMALISASI For k = 0 To tabel_Normalisasi(0).Cols - 1 nilai1 = Val(tabel_Normalisasi(0).TextMatrix(1, k))

10

If nilai1 > Max Then Max = nilai1 Label0.Caption = Max End If Next k For k = 0 To tabel_Normalisasi(0).Cols - 1 tabel_Normalisasi(0).TextMatrix(1, k) = Val(tabel_Normalisasi(0).TextMatrix(1, k)) / Val(Label0.Caption) tabel_Normalisasi(0).TextMatrix(1, k) = Format(tabel_Normalisasi(0).TextMatrix(1, k), "0.0000") Next k End Sub Private Sub Cmd_Pixel1_Click() tabel_Input(1).Cols = 16 tabel_Input(1).Rows = 16 '''''''''''''ANGKA BARIS & KOLOM For c = 1 To tabel_Input(1).Cols - 1 For r = 1 To tabel_Input(1).Rows - 1 tabel_Input(1).TextMatrix(r, 0) = r tabel_Input(1).TextMatrix(0, c) = c Next r Next c ''''''''''''''NGAMBIL PIXEL For X = 1 To tabel_Input(1).Rows - 1 For Y = 1 To tabel_Input(1).Cols - 1 pixels(X, Y) = Gambar(1).Point(Y, X) Next Y Next X ''''''''''''''NULIS NILAI

11

For X = 1 To tabel_Input(1).Rows - 1 For Y = 1 To tabel_Input(1).Cols - 1 r = pixels(X, Y) And &HFF g = (pixels(X, Y) And &HFF00 / &H100) Mod &H100 b = (pixels(X, Y) And &HFF0000 / &H10000) Mod &H100 Grey = (r + g + b) / 3 tabel_Input(1).TextMatrix(X, Y) = Grey Next Y Next X

''''''''''''MBUAT MATRIK JADI SATU BARIS tabel_Normalisasi(1).Cols = (tabel_Input(1).Cols - 1) * (tabel_Input(1).Rows - 1) For c = 1 To Val(tabel_Normalisasi(1).Cols) tabel_Normalisasi(1).TextMatrix(0, c - 1) = c Next c

''''''''''''NILAI JADI SATU BARIS For X = 1 To tabel_Input(1).Rows - 1 For Y = 1 To tabel_Input(1).Cols - 1 c = 15 * (X - 1) + Y tabel_Normalisasi(1).TextMatrix(1, c - 1) = Val(tabel_Input(1).TextMatrix(X, Y)) Next Y Next X

''''''''''''NORMALISASI For k = 0 To tabel_Normalisasi(1).Cols - 1

12

nilai1 = Val(tabel_Normalisasi(1).TextMatrix(1, k)) If nilai1 > Max Then Max = nilai1 Label1.Caption = Max End If Next k For k = 0 To tabel_Normalisasi(1).Cols - 1 tabel_Normalisasi(1).TextMatrix(1, k) = Val(tabel_Normalisasi(1).TextMatrix(1, k)) / Val(Label1.Caption) tabel_Normalisasi(1).TextMatrix(1, k) = Format(tabel_Normalisasi(1).TextMatrix(1, k), "0.0000") Next k End Sub Private Sub Cmd_Pixel2_Click() tabel_Input(2).Cols = 16 tabel_Input(2).Rows = 16 '''''''''''''ANGKA BARIS & KOLOM For c = 1 To tabel_Input(2).Cols - 1 For r = 1 To tabel_Input(2).Rows - 1 tabel_Input(2).TextMatrix(r, 0) = r tabel_Input(2).TextMatrix(0, c) = c Next r Next c ''''''''''''''NGAMBIL PIXEL For X = 1 To tabel_Input(2).Rows - 1 For Y = 1 To tabel_Input(2).Cols - 1 pixels(X, Y) = Gambar(2).Point(Y, X) Next Y Next X

13

''''''''''''''NULIS NILAI For X = 1 To tabel_Input(2).Rows - 1 For Y = 1 To tabel_Input(2).Cols - 1 r = pixels(X, Y) And &HFF g = (pixels(X, Y) And &HFF00 / &H100) Mod &H100 b = (pixels(X, Y) And &HFF0000 / &H10000) Mod &H100 Grey = (r + g + b) / 3 tabel_Input(2).TextMatrix(X, Y) = Grey Next Y Next X ''''''''''''MBUAT MATRIK JADI SATU BARIS tabel_Normalisasi(2).Cols = (tabel_Input(2).Cols - 1) * (tabel_Input(2).Rows - 1) For c = 1 To Val(tabel_Normalisasi(2).Cols) tabel_Normalisasi(2).TextMatrix(0, c - 1) = c Next c ''''''''''''NILAI JADI SATU BARIS For X = 1 To tabel_Input(2).Rows - 1 For Y = 1 To tabel_Input(2).Cols - 1 c = 15 * (X - 1) + Y tabel_Normalisasi(2).TextMatrix(1, c - 1) = Val(tabel_Input(2).TextMatrix(X, Y)) Next Y Next X ''''''''''''NORMALISASI For k = 0 To tabel_Normalisasi(2).Cols - 1 nilai1 = Val(tabel_Normalisasi(2).TextMatrix(1, k)) If nilai1 > Max Then

14

Max = nilai1 Label2.Caption = Max End If Next k For k = 0 To tabel_Normalisasi(2).Cols - 1 tabel_Normalisasi(2).TextMatrix(1, k) = Val(tabel_Normalisasi(2).TextMatrix(1, k)) / Val(Label2.Caption) tabel_Normalisasi(2).TextMatrix(1, k) = Format(tabel_Normalisasi(2).TextMatrix(1, k), "0.0000") Next k End Sub Private Sub Cmd_Pixel3_Click() tabel_Input(3).Cols = 16 tabel_Input(3).Rows = 16 '''''''''''''ANGKA BARIS & KOLOM For c = 1 To tabel_Input(3).Cols - 1 For r = 1 To tabel_Input(3).Rows - 1 tabel_Input(3).TextMatrix(r, 0) = r tabel_Input(3).TextMatrix(0, c) = c Next r Next c ''''''''''''''NGAMBIL PIXEL For X = 1 To tabel_Input(3).Rows - 1 For Y = 1 To tabel_Input(3).Cols - 1 pixels(X, Y) = Gambar(3).Point(Y, X) Next Y Next X ''''''''''''''NULIS NILAI For X = 1 To tabel_Input(3).Rows - 1

15

For Y = 1 To tabel_Input(3).Cols - 1 r = pixels(X, Y) And &HFF g = (pixels(X, Y) And &HFF00 / &H100) Mod &H100 b = (pixels(X, Y) And &HFF0000 / &H10000) Mod &H100 Grey = (r + g + b) / 3 tabel_Input(3).TextMatrix(X, Y) = Grey Next Y Next X ''''''''''''MBUAT MATRIK JADI SATU BARIS tabel_Normalisasi(3).Cols = (tabel_Input(3).Cols - 1) * (tabel_Input(3).Rows - 1) For c = 1 To Val(tabel_Normalisasi(3).Cols) tabel_Normalisasi(3).TextMatrix(0, c - 1) = c Next c ''''''''''''NILAI JADI SATU BARIS For X = 1 To tabel_Input(3).Rows - 1 For Y = 1 To tabel_Input(3).Cols - 1 c = 15 * (X - 1) + Y tabel_Normalisasi(3).TextMatrix(1, c - 1) = Val(tabel_Input(3).TextMatrix(X, Y)) Next Y Next X ''''''''''''NORMALISASI For k = 0 To tabel_Normalisasi(3).Cols - 1 nilai1 = Val(tabel_Normalisasi(3).TextMatrix(1, k)) If nilai1 > Max Then Max = nilai1 Label3.Caption = Max

16

End If Next k For k = 0 To tabel_Normalisasi(3).Cols - 1 tabel_Normalisasi(3).TextMatrix(1, k) = Val(tabel_Normalisasi(3).TextMatrix(1, k)) / Val(Label3.Caption) tabel_Normalisasi(3).TextMatrix(1, k) = Format(tabel_Normalisasi(3).TextMatrix(1, k), "0.0000") Next k End Sub Private Sub Cmd_Pixel4_Click() tabel_Input(4).Cols = 16 tabel_Input(4).Rows = 16 '''''''''''''ANGKA BARIS & KOLOM For c = 1 To tabel_Input(4).Cols - 1 For r = 1 To tabel_Input(4).Rows - 1 tabel_Input(4).TextMatrix(r, 0) = r tabel_Input(4).TextMatrix(0, c) = c Next r Next c ''''''''''''''NGAMBIL PIXEL For X = 1 To tabel_Input(4).Rows - 1 For Y = 1 To tabel_Input(4).Cols - 1 pixels(X, Y) = Gambar(4).Point(Y, X) Next Y Next X ''''''''''''''NULIS NILAI For X = 1 To tabel_Input(4).Rows - 1 For Y = 1 To tabel_Input(4).Cols - 1

17

r = pixels(X, Y) And &HFF g = (pixels(X, Y) And &HFF00 / &H100) Mod &H100 b = (pixels(X, Y) And &HFF0000 / &H10000) Mod &H100 Grey = (r + g + b) / 3 tabel_Input(4).TextMatrix(X, Y) = Grey Next Y Next X ''''''''''''MBUAT MATRIK JADI SATU BARIS tabel_Normalisasi(4).Cols = (tabel_Input(4).Cols - 1) * (tabel_Input(4).Rows - 1) For c = 1 To Val(tabel_Normalisasi(4).Cols) tabel_Normalisasi(4).TextMatrix(0, c - 1) = c Next c ''''''''''''NILAI JADI SATU BARIS For X = 1 To tabel_Input(4).Rows - 1 For Y = 1 To tabel_Input(4).Cols - 1 c = 15 * (X - 1) + Y tabel_Normalisasi(4).TextMatrix(1, c - 1) = Val(tabel_Input(4).TextMatrix(X, Y)) Next Y Next X ''''''''''''NORMALISASI For k = 0 To tabel_Normalisasi(4).Cols - 1 nilai1 = Val(tabel_Normalisasi(4).TextMatrix(1, k)) If nilai1 > Max Then Max = nilai1 Label4.Caption = Max End If

18

Next k For k = 0 To tabel_Normalisasi(3).Cols - 1 tabel_Normalisasi(4).TextMatrix(1, k) = Val(tabel_Normalisasi(4).TextMatrix(1, k)) / Val(Label4.Caption) tabel_Normalisasi(4).TextMatrix(1, k) = Format(tabel_Normalisasi(3).TextMatrix(1, k), "0.0000") Next k End Sub Private Sub Cmd_Pixel5_Click() tabel_Input(5).Cols = 16 tabel_Input(5).Rows = 21 '''''''''''''ANGKA BARIS & KOLOM For c = 1 To tabel_Input(5).Cols - 1 For r = 1 To tabel_Input(5).Rows - 1 tabel_Input(5).TextMatrix(r, 0) = r tabel_Input(5).TextMatrix(0, c) = c Next r Next c ''''''''''''''NGAMBIL PIXEL For X = 1 To tabel_Input(5).Rows - 1 For Y = 1 To tabel_Input(5).Cols - 1 pixels(X, Y) = Gambar(5).Point(Y, X) Next Y Next X ''''''''''''''NULIS NILAI For X = 1 To tabel_Input(5).Rows - 1 For Y = 1 To tabel_Input(5).Cols - 1 r = pixels(X, Y) And &HFF g = (pixels(X, Y) And &HFF00 / &H100) Mod &H100

19

b = (pixels(X, Y) And &HFF0000 / &H10000) Mod &H100 Grey = (r + g + b) / 3 tabel_Input(5).TextMatrix(X, Y) = Grey Next Y Next X ''''''''''''MBUAT MATRIK JADI SATU BARIS tabel_Normalisasi(5).Cols = (tabel_Input(5).Cols - 1) * (tabel_Input(5).Rows - 1) For c = 1 To Val(tabel_Normalisasi(5).Cols) tabel_Normalisasi(5).TextMatrix(0, c - 1) = c Next c ''''''''''''NILAI JADI SATU BARIS For X = 1 To tabel_Input(5).Rows - 1 For Y = 1 To tabel_Input(5).Cols - 1 c = 15 * (X - 1) + Y tabel_Normalisasi(5).TextMatrix(1, c - 1) = Val(tabel_Input(5).TextMatrix(X, Y)) Next Y Next X ''''''''''''NORMALISASI For k = 0 To tabel_Normalisasi(5).Cols - 1 nilai1 = Val(tabel_Normalisasi(5).TextMatrix(1, k)) If nilai1 > Max Then Max = nilai1 Label5.Caption = Max End If Next k

20

For k = 0 To tabel_Normalisasi(5).Cols - 1 tabel_Normalisasi(5).TextMatrix(1, k) = Val(tabel_Normalisasi(5).TextMatrix(1, k)) / Val(Label5.Caption) tabel_Normalisasi(5).TextMatrix(1, k) = Format(tabel_Normalisasi(5).TextMatrix(1, k), "0.0000") Next k End Sub Private Sub Cmd_Pixel6_Click() tabel_Input(6).Cols = 16 tabel_Input(6).Rows = 21 '''''''''''''ANGKA BARIS & KOLOM For c = 1 To tabel_Input(6).Cols - 1 For r = 1 To tabel_Input(6).Rows - 1 tabel_Input(6).TextMatrix(r, 0) = r tabel_Input(6).TextMatrix(0, c) = c Next r Next c ''''''''''''''NGAMBIL PIXEL For X = 1 To tabel_Input(6).Rows - 1 For Y = 1 To tabel_Input(6).Cols - 1 pixels(X, Y) = Gambar(6).Point(Y, X) Next Y Next X ''''''''''''''NULIS NILAI For X = 1 To tabel_Input(6).Rows - 1 For Y = 1 To tabel_Input(6).Cols - 1 r = pixels(X, Y) And &HFF g = (pixels(X, Y) And &HFF00 / &H100) Mod &H100 b = (pixels(X, Y) And &HFF0000 / &H10000) Mod &H100

21

Grey = (r + g + b) / 3 tabel_Input(6).TextMatrix(X, Y) = Grey Next Y Next X ''''''''''''MBUAT MATRIK JADI SATU BARIS tabel_Normalisasi(6).Cols = (tabel_Input(6).Cols - 1) * (tabel_Input(6).Rows - 1) For c = 1 To Val(tabel_Normalisasi(6).Cols) tabel_Normalisasi(6).TextMatrix(0, c - 1) = c Next c ''''''''''''NILAI JADI SATU BARIS For X = 1 To tabel_Input(6).Rows - 1 For Y = 1 To tabel_Input(6).Cols - 1 c = 15 * (X - 1) + Y tabel_Normalisasi(6).TextMatrix(1, c - 1) = Val(tabel_Input(6).TextMatrix(X, Y)) Next Y Next X ''''''''''''NORMALISASI For k = 0 To tabel_Normalisasi(6).Cols - 1 nilai1 = Val(tabel_Normalisasi(6).TextMatrix(1, k)) If nilai1 > Max Then Max = nilai1 Label6.Caption = Max End If Next k For k = 0 To tabel_Normalisasi(6).Cols - 1

22

tabel_Normalisasi(6).TextMatrix(1, k) = Val(tabel_Normalisasi(6).TextMatrix(1, k)) / Val(Label6.Caption) tabel_Normalisasi(6).TextMatrix(1, k) = Format(tabel_Normalisasi(6).TextMatrix(1, k), "0.0000") Next k End Sub Private Sub Cmd_Pixel7_Click() tabel_Input(7).Cols = 16 tabel_Input(7).Rows = 21 '''''''''''''ANGKA BARIS & KOLOM For c = 1 To tabel_Input(7).Cols - 1 For r = 1 To tabel_Input(7).Rows - 1 tabel_Input(7).TextMatrix(r, 0) = r tabel_Input(7).TextMatrix(0, c) = c Next r Next c ''''''''''''''NGAMBIL PIXEL For X = 1 To tabel_Input(7).Rows - 1 For Y = 1 To tabel_Input(7).Cols - 1 pixels(X, Y) = Gambar(7).Point(Y, X) Next Y Next X ''''''''''''''NULIS NILAI For X = 1 To tabel_Input(7).Rows - 1 For Y = 1 To tabel_Input(7).Cols - 1 r = pixels(X, Y) And &HFF g = (pixels(X, Y) And &HFF00 / &H100) Mod &H100 b = (pixels(X, Y) And &HFF0000 / &H10000) Mod &H100 Grey = (r + g + b) / 3

23

tabel_Input(7).TextMatrix(X, Y) = Grey Next Y Next X ''''''''''''MBUAT MATRIK JADI SATU BARIS tabel_Normalisasi(7).Cols = (tabel_Input(7).Cols - 1) * (tabel_Input(7).Rows - 1) For c = 1 To Val(tabel_Normalisasi(7).Cols) tabel_Normalisasi(7).TextMatrix(0, c - 1) = c Next c ''''''''''''NILAI JADI SATU BARIS For X = 1 To tabel_Input(7).Rows - 1 For Y = 1 To tabel_Input(7).Cols - 1 c = 15 * (X - 1) + Y tabel_Normalisasi(7).TextMatrix(1, c - 1) = Val(tabel_Input(7).TextMatrix(X, Y)) Next Y Next X ''''''''''''NORMALISASI For k = 0 To tabel_Normalisasi(7).Cols - 1 nilai1 = Val(tabel_Normalisasi(7).TextMatrix(1, k)) If nilai1 > Max Then Max = nilai1 Label7.Caption = Max End If Next k For k = 0 To tabel_Normalisasi(3).Cols - 1

24

tabel_Normalisasi(7).TextMatrix(1, k) = Val(tabel_Normalisasi(7).TextMatrix(1, k)) / Val(Label7.Caption) tabel_Normalisasi(7).TextMatrix(1, k) = Format(tabel_Normalisasi(7).TextMatrix(1, k), "0.0000") Next k End Sub Private Sub Cmd_Oke_Click() If Val(txt_alpha.Text) > 1 Or Val(txt_alpha.Text) < 0 Then '----------------------ulang nilai alpha jika salah-------------------------MsgBox "Masukkan nilai alpha 0 sampai 1", vbOKOnly, "ulang" txt_alpha.Text = "0.5" txt_alpha.SetFocus Exit Sub ElseIf Val(txt_momentum.Text) > 1 Or Val(txt_momentum.Text) < 0 Then '--------------------------ulang nilai momentum jika salah---------------------------------MsgBox "Masukkan nilai momentum 0 sampai 1", vbOKOnly, "ulang" txt_momentum.Text = "0.5" txt_momentum.SetFocus Exit Sub ElseIf Val(txt_epoch.Text) > 50000 Or Val(txt_epoch.Text) < 0 Then '--------------------------ulang nilai epoch jika salah---------------------------------MsgBox "Masukkan nilai batas epoch 0 sampai 50000", vbOKOnly, "ulang" txt_epoch.Text = "500"

25

txt_epoch.SetFocus Exit Sub ElseIf Txt_GbrInput.Text > 4 Or Txt_GbrInput.Text < 1 Then '--------------------------mengatur jumlah gambar inputan training----------------------------MsgBox "Masukkan jumlah input antara 1 sampai 4 gambar", vbOKOnly, "ulang" Cmd_Gambar0.Enabled = False Cmd_Gambar1.Enabled = False Cmd_Gambar2.Enabled = False Cmd_Gambar3.Enabled = False Cmd_Pixel0.Enabled = False Cmd_Pixel1.Enabled = False Cmd_Pixel2.Enabled = False Cmd_Pixel3.Enabled = False Txt_GbrInput.Text = "4" Txt_GbrInput.SetFocus Exit Sub Else If Txt_GbrInput.Text = 1 Then Cmd_Gambar0.Enabled = True Cmd_Gambar1.Enabled = False Cmd_Gambar2.Enabled = False Cmd_Gambar3.Enabled = False Cmd_Pixel0.Enabled = True Cmd_Pixel1.Enabled = False Cmd_Pixel2.Enabled = False Cmd_Pixel3.Enabled = False ElseIf Txt_GbrInput.Text = 2 Then

26

Cmd_Gambar0.Enabled = True Cmd_Gambar1.Enabled = True Cmd_Gambar2.Enabled = False Cmd_Gambar3.Enabled = False Cmd_Pixel0.Enabled = True Cmd_Pixel1.Enabled = True Cmd_Pixel2.Enabled = False Cmd_Pixel3.Enabled = False ElseIf Txt_GbrInput.Text = 3 Then Cmd_Gambar0.Enabled = True Cmd_Gambar1.Enabled = True Cmd_Gambar2.Enabled = True Cmd_Gambar3.Enabled = False Cmd_Pixel0.Enabled = True Cmd_Pixel1.Enabled = True Cmd_Pixel2.Enabled = True Cmd_Pixel3.Enabled = False ElseIf Txt_GbrInput.Text = 4 Then Cmd_Gambar0.Enabled = True Cmd_Gambar1.Enabled = True Cmd_Gambar2.Enabled = True Cmd_Gambar3.Enabled = True Cmd_Pixel0.Enabled = True Cmd_Pixel1.Enabled = True Cmd_Pixel2.Enabled = True Cmd_Pixel3.Enabled = True End If '---------------------------------nilai parameter JST di label lain-----------------------

27

Label30.Caption = txt_alpha Label39.Caption = txt_alpha Label29.Caption = txt_hidden Label40.Caption = txt_hidden Label31.Caption = txt_momentum Label38.Caption = txt_momentum Label32.Caption = txt_error Label37.Caption = txt_error Label33.Caption = txt_epoch Label36.Caption = txt_epoch Label34.Caption = txt_target Label35.Caption = txt_target SSTab1.Tab = 1 End If End Sub Private Sub Cmd_gambar_Testing_Click() With CmnDialog(8) .DialogTitle = "gambar input" .CancelError = False .InitDir = "h:\data TA\" .Filter = "Picture File |*.jpg" .ShowOpen File_name = .FileName Gambar(8).Picture = LoadPicture(File_name) End With End Sub Private Sub Cmd_Pixel_Testing_Click() tabel_Input(8).Cols = 26 tabel_Input(8).Rows = 26 '''''''''''''ANGKA BARIS & KOLOM For c = 1 To tabel_Input(8).Cols - 1

28

For r = 1 To tabel_Input(8).Rows - 1 tabel_Input(8).TextMatrix(r, 0) = r tabel_Input(8).TextMatrix(0, c) = c Next r Next c ''''''''''''''NGAMBIL PIXEL For X = 1 To tabel_Input(8).Rows - 1 For Y = 1 To tabel_Input(8).Cols - 1 pixels(X, Y) = Gambar(8).Point(Y, X) Next Y Next X ''''''''''''''NULIS NILAI For X = 1 To tabel_Input(8).Rows - 1 For Y = 1 To tabel_Input(8).Cols - 1 r = pixels(X, Y) And &HFF g = (pixels(X, Y) And &HFF00 / &H100) Mod &H100 b = (pixels(X, Y) And &HFF0000 / &H10000) Mod &H100 Grey = (r + g + b) / 3 tabel_Input(8).TextMatrix(X, Y) = Grey Next Y Next X ''''''''''''MBUAT MATRIK JADI SATU BARIS tabel_Normalisasi(8).Cols = (tabel_Input(8).Cols - 1) * (tabel_Input(8).Rows - 1) For c = 1 To Val(tabel_Normalisasi(8).Cols) tabel_Normalisasi(8).TextMatrix(0, c - 1) = c Next c ''''''''''''NILAI JADI SATU BARIS For X = 1 To tabel_Input(8).Rows - 1

29

For Y = 1 To tabel_Input(8).Cols - 1 c = 15 * (X - 1) + Y tabel_Normalisasi(8).TextMatrix(1, c - 1) = Val(tabel_Input(8).TextMatrix(X, Y)) Next Y Next X ''''''''''''NORMALISASI For k = 0 To tabel_Normalisasi(8).Cols - 1 nilai1 = Val(tabel_Normalisasi(8).TextMatrix(1, k)) If nilai1 > Max Then Max = nilai1 Label60.Caption = Max End If Next k For k = 0 To tabel_Normalisasi(8).Cols - 1 tabel_Normalisasi(8).TextMatrix(1, k) = Val(tabel_Normalisasi(8).TextMatrix(1, k)) / Val(Label60.Caption) tabel_Normalisasi(8).TextMatrix(1, k) = Format(tabel_Normalisasi(8).TextMatrix(1, k), "0.0000") Next k '----------------------tabel Vij testing--------------With tabel_Vij_testing .Rows = tabel_Normalisasi(8).Cols + 2 .Cols = Val(txt_hidden2) + 1 .ColWidth(0) = 500 For i = 1 To .Rows - 2 For j = 1 To .Cols - 1 .TextMatrix(i, 0) = i

30

.TextMatrix(0, j) = j .TextMatrix(.Rows - 1, 0) = "BIAS" Next j Next i End With '----------------------------tabel Wjk testing-------With tabel_Wjk_testing .Rows = Val(txt_hidden2) + 2 .Cols = 2 .ColWidth(0) = 500 .ColWidth(1) = 2000 For j = 1 To .Rows - 2 .TextMatrix(j, 0) = j Next j .TextMatrix(.Rows - 1, 0) = "BIAS" End With End Sub Private Sub Cmd_Load_Bobot_Click() Dim Data, jml, DA, target As Double '-----------------------------tabel_vij testing-------'---------------------------------tabel_Z in testing--With tabel_Zin_Testing .Rows = 2 .Cols = Val(txt_hidden2) For j = 0 To Val(txt_hidden2) - 1 .TextMatrix(0, j) = j + 1 .ColWidth(j) = 2000 Next j

31

End With '--------------------------------tabel Z testing------With tabel_Z_Testing .Rows = tabel_Zin_Testing.Rows .Cols = tabel_Zin_Testing.Cols For j = 0 To Val(txt_hidden2) - 1 .TextMatrix(0, j) = j + 1 .ColWidth(j) = 2000 Next j End With '-----------------------------tabel Y in testing------tabel_Yin_Testing.TextMatrix(0, 0) = "Output" tabel_Yin_Testing.ColWidth(0) = 2000 '-------------------------------tabel Y testing-------tabel_Y_Testing.TextMatrix(0, 0) = "Output" tabel_Y_Testing.ColWidth(0) = 2000 '---------------------------------load data-----------Dim jumlah_Data As Double With CommonDialog1 .FileName = "" .Filter = "File Data TA (*.txt)|*.txt" .InitDir = "D:\JST Tahu\Jst Tahu\" .ShowOpen Open .FileName For Input As #1 End With With tabel_Vij_testing For j = 1 To .Cols - 1 For i = 1 To .Rows - 1 Input #1, Data .TextMatrix(i, j) = Data

32

Next i Next j End With With tabel_Wjk_testing For j = 1 To .Rows - 1 Input #1, DA .TextMatrix(j, 1) = DA Next j End With Input #1, target txt_target2.Text = target Close #1 End Sub Private Sub Cmd_testing_Click() ReDim Z_in_Tes(1, Val(txt_hidden2) - 1) As Double With tabel_Zin_Testing .Clear For c = 0 To tabel_Zin_Testing.Cols - 1 For X = 0 To tabel_Normalisasi(8).Cols - 1 .TextMatrix(0, c) = c + 1 .TextMatrix(1, c) = Val(tabel_Zin_Testing.TextMatrix(1, c)) + (Val(tabel_Normalisasi(8).TextMatrix(1, X)) * (Val(tabel_Vij_testing.TextMatrix(X + 1, c + 1)))) Z_in_Tes(1, c) = tabel_Zin_Testing.TextMatrix(1, c) Next X Next c End With For c = 0 To Val(txt_hidden2) - 1 tabel_Zin_Testing.TextMatrix(1, c) = Val(Z_in_Tes(1, c)) +

33

Val(tabel_Vij_testing.TextMatrix(tabel_Vij_testing.Rows - 1, c + 1)) Next c '--------------------------------Z testing---------For n = 0 To Val(txt_hidden2) - 1 With tabel_Z_Testing .TextMatrix(1, n) = f(Val(tabel_Zin_Testing.TextMatrix(1, n))) .TextMatrix(0, n) = n + 1 End With Next n

'------------------NILAI Y_in testing----------------- For n = 0 To tabel_Yin_Testing.Cols - 1 For X = 0 To tabel_Z_Testing.Cols - 1 tabel_Yin_Testing.Clear ReDim Y_in_Tes(1, n) As Double With tabel_Yin_Testing .TextMatrix(1, n) = Val(tabel_Yin_Testing.TextMatrix(1, n)) + (Val(tabel_Z_Testing.TextMatrix(1, X)) * (Val(tabel_Wjk_testing.TextMatrix(X + 1, n + 1)))) .TextMatrix(0, n) = n + 1 End With Next X Next n '--------NILAI Y testing (OUT)-----------------------' For n = 0 To tabel_Yin_Testing.Cols - 1 tabel_Y_Testing.TextMatrix(1, n) = f(Val(tabel_Yin_Testing.TextMatrix(1, n))) tabel_Y_Testing.TextMatrix(0, n) = n + 1

34

Next n Label50.Caption = Val(txt_target2.Text) Val(tabel_Y_Testing.TextMatrix(1, 0)) Label50.Caption = Format(Label50.Caption, "0.00000000") If Val(Abs(Label50.Caption)) <= Val(Txt_batas.Text) Then Label51.Caption = "Tahu Kuning Buatan" Else Label51.Caption = "Tahu Kuning Alami" End If End Sub Private Sub Combo_Click() If Combo.Text = "V1" Then Txt_batas.Text = 0.00024726 ElseIf Combo.Text = "V2" Then Txt_batas.Text = 0.0030614 ElseIf Combo.Text = "v3" Then Txt_batas.Text = 0.00077968 Else Txt_batas.Text = 0.00024692 End If End Sub Private Sub Command1_Click() tabel_Vij_testing.Clear tabel_Wjk_testing.Clear End Sub Private Sub Command10_Click() Frame14.Visible = True With Image5 .Left = 3840

35

.Width = 11000 End With Command10.Visible = False End Sub Private Sub Cmd_Random_Click() For c = 0 To Val(txt_hidden) - 1 tabel_Zin.Cols = Val(txt_hidden) tabel_Zin.ColWidth(c) = 2000 tabel_Z.Cols = Val(txt_hidden) tabel_Z.TextMatrix(0, c) = c + 1 tabel_Z.ColWidth(c) = 2000 Next c '--------------MASUKKAN JUMLAH HIDDEN LAYER--------' With tabel_Vij_awal .Rows = ((tabel_Input(0).Rows - 1) * (tabel_Input(0).Cols - 1)) + 2 .Cols = Val(txt_hidden) + 1 For i = 1 To tabel_Vij_awal.Rows - 2 For j = 1 To Val(txt_hidden) .TextMatrix(0, j) = j .TextMatrix(i, j) = ((Int(11 * Rnd) - 5) / 10) + ((Int(11 * Rnd) - 5) / 100) If .TextMatrix(i, j) > 0.5 Then .TextMatrix(i, j) = 0.5 ElseIf .TextMatrix(i, j) < -0.5 Then .TextMatrix(i, j) = -0.5 End If .TextMatrix(i, 0) = i .TextMatrix(tabel_Vij_awal.Rows - 1, 0) = " BIAS"

36

.TextMatrix(tabel_Vij_awal.Rows - 1, j) = ((Int(11 * Rnd) - 5) / 10) + ((Int(11 * Rnd) - 5) / 100) If .TextMatrix(tabel_Vij_awal.Rows - 1, j) > 0.5 Then .TextMatrix(tabel_Vij_awal.Rows - 1, j) = 0.5 ElseIf .TextMatrix(tabel_Vij_awal.Rows - 1, j) > 0.5 Then .TextMatrix(tabel_Vij_awal.Rows - 1, j) = 0.5 .TextMatrix(0, 0) = " I \ J" End If Next j Next i End With '------------------------RANDOM BOBOT W----' For j = 1 To Val(txt_hidden) With tabel_Wjk .Rows = Val(txt_hidden) + 2 .TextMatrix(j, 0) = j .TextMatrix(j, 1) = ((Int(11 * Rnd) - 5) / 10) + ((Int(11 * Rnd) - 5) / 100) If .TextMatrix(j, 1) > 0.5 Then .TextMatrix(j, 1) = 0.5 ElseIf .TextMatrix(j, 1) < -0.5 Then .TextMatrix(j, 1) = -0.5 End If .TextMatrix(0, 1) = " 1" .TextMatrix(Val(txt_hidden) + 1, 0) = " BIAS" .TextMatrix(Val(txt_hidden) + 1, 1) = ((Int(11 * Rnd) - 5) / 10) + ((Int(11 * Rnd) - 5) / 100) If .TextMatrix(Val(txt_hidden) + 1, 1) > 0.5 Then

37

.TextMatrix(Val(txt_hidden) + 1, 1) = 0.5 ElseIf .TextMatrix(Val(txt_hidden) + 1, 1) < -0.5 Then .TextMatrix(Val(txt_hidden) + 1, 1) = -0.5 End If .TextMatrix(0, 0) = " J \ K" End With Next j

'----------------------Vij_akhir--------------' For i = 1 To tabel_Vij_awal.Rows - 2 For j = 1 To Val(txt_hidden) With tabel_Vij_Akhir .Cols = tabel_Vij_awal.Cols .Rows = tabel_Vij_awal.Rows .TextMatrix(0, j) = j .TextMatrix(i, 0) = i .TextMatrix(tabel_Vij_awal.Rows - 1, 0) = " BIAS" .TextMatrix(i, j) = tabel_Vij_awal.TextMatrix(i, j) .TextMatrix(tabel_Vij_Akhir.Rows - 1, j) = tabel_Vij_awal.TextMatrix(tabel_Vij_awal.Rows - 1, j) End With With tabel_last_deltaVij .Cols = tabel_Vij_awal.Cols .Rows = tabel_Vij_awal.Rows .TextMatrix(0, j) = j .TextMatrix(i, 0) = i End With Next j Next i

38

'-------------------Wjk_akhir-------------------------' For j = 1 To tabel_Wjk.Rows - 2 For k = 1 To tabel_Wjk.Cols - 1 With tabel_Wjk_Akhir .Cols = tabel_Wjk.Cols .Rows = tabel_Wjk.Rows .TextMatrix(j, 0) = j .TextMatrix(0, k) = k .TextMatrix(tabel_Wjk.Rows - 1, 0) = " BIAS" .TextMatrix(j, 1) = tabel_Wjk.TextMatrix(j, 1) .TextMatrix(Val(txt_hidden) + 1, 1) = tabel_Wjk.TextMatrix(Val(txt_hidden) + 1, 1) End With Next k Next j '--------------last_deltaWjk-------------------- For n = 1 To Val(txt_hidden) With tabel_last_deltaWjk .Cols = 2 .Rows = Val(txt_hidden) + 2 .TextMatrix(n, 1) = 0 .TextMatrix(n, 0) = n .TextMatrix(n + 1, 0) = " BIAS" .ColWidth(0) = 500 End With Next n End Sub Private Sub Cmd_Training_Click() txt_hidden2.Text = Val(txt_hidden.Text) txt_alpha2.Text = Val(txt_alpha.Text) txt_momentum2.Text = Val(txt_momentum.Text)

39

SSTab1.Tab = 3 Dim r As Double For t = 1 To Val(txt_epoch) For q = 0 To Val(Txt_GbrInput.Text) - 1 ReDim Errors(4) As Double ReDim last_wjk(txt_hidden, 1), last_w0(1), last_vij(tabel_Normalisasi(0).Cols, Val(txt_hidden)), last_v0(Val(txt_hidden)) As Double ReDim Z_in(1, Val(txt_hidden) - 1) As Double ReDim S_in(Val(txt_hidden)), deltaWjk(Val(txt_hidden), 1), S(Val(txt_hidden)), deltaVij(tabel_Normalisasi(0).Cols, Val(txt_hidden)), deltaW0(1), deltaV0(Val(txt_hidden)) As Double ReDim last_deltaWjk(txt_hidden - 1, 1), last_deltaVij(tabel_Normalisasi(0).Cols, Val(txt_hidden)), deltaW0(1), deltaV0(Val(txt_hidden)) As Double '-----------------------------------------------------' With tabel_Zin .Clear For c = 0 To tabel_Zin.Cols - 1 For X = 0 To tabel_Normalisasi(q).Cols - 1 .TextMatrix(0, c) = c + 1 .TextMatrix(1, c) = Val(tabel_Zin.TextMatrix(1, c)) + (Val(tabel_Normalisasi(q).TextMatrix(1, X)) * (Val(tabel_Vij_Akhir.TextMatrix(X + 1, c + 1)))) Z_in(1, c) = tabel_Zin.TextMatrix(1, c) Next X Next c For c = 0 To Val(txt_hidden) - 1 tabel_Zin.TextMatrix(1, c) = Val(Z_in(1, c)) + Val(tabel_Vij_Akhir.TextMatrix(tabel_Vij_Akhir.Rows 1, c + 1))

40

Next c End With DoEvents

'------------------NILAI Z-------------------------' For n = 0 To Val(txt_hidden) - 1 With tabel_Z .TextMatrix(1, n) = f(Val(tabel_Zin.TextMatrix(1, n))) End With Next n '-------------------NILAI Y_in------------------------' For n = 0 To tabel_Yin.Cols - 1 For X = 0 To tabel_Z.Cols - 1 tabel_Yin.Clear ReDim Y_in(1, n) As Double With tabel_Yin .TextMatrix(1, n) = Val(tabel_Yin.TextMatrix(1, n)) + (Val(tabel_Z.TextMatrix(1, X)) * (Val(tabel_Wjk_Akhir.TextMatrix(X + 1, n + 1)))) .TextMatrix(0, n) = n + 1 End With Next X Next n

'-----------------------NILAI Y (OUT)---------------- ' For n = 0 To tabel_Yin.Cols - 1 tabel_Y.TextMatrix(1, n) = f(Val(tabel_Yin.TextMatrix(1, n))) tabel_Y.TextMatrix(0, n) = n + 1 Next n

41

DoEvents r = 0 For n = 0 To tabel_Yin.Cols - 1 Error = (Val(txt_target.Text) Val(tabel_Y.TextMatrix(1, n))) ^ 2 r = r + Error Next n txt_target2.Text = Val(tabel_Y.TextMatrix(1, 0)) For j = 1 To Val(txt_hidden) last_wjk(j, 1) = tabel_Wjk_Akhir.TextMatrix(j, 1) last_w0(1) = tabel_Wjk_Akhir.TextMatrix(tabel_Wjk_Akhir.Rows - 1, 1) Next j For i = 0 To tabel_Normalisasi(0).Cols - 1 For j = 1 To Val(txt_hidden) last_vij(i, j) = tabel_Vij_Akhir.TextMatrix(i + 1, j) last_v0(j) = tabel_Vij_Akhir.TextMatrix(tabel_Vij_Akhir.Rows - 1, j) Next j Next i '-------------------S------------------------------' ss = (Val(txt_target.Text) - Val(tabel_Y.TextMatrix(1, 0))) * df(tabel_Yin.TextMatrix(1, 0)) Text3.Text = Format(ss, "0.00000") '-----------------delta Wjk------------------------' For n = 0 To Val(txt_hidden) - 1 deltaWjk(n, 1) = (Val(txt_alpha) * Text3.Text * Val(tabel_Z.TextMatrix(1, n))) + (Val(txt_momentum) * tabel_last_deltaWjk.TextMatrix(n + 1, 1)) last_deltaWjk(n, 1) = deltaWjk(n, 1)

42

tabel_last_deltaWjk.TextMatrix(n + 1, 1) = last_deltaWjk(n, 1) Next n '---------------------delta W0-----------------------deltaW0(1) = Val(txt_alpha) * Text3.Text tabel_last_deltaWjk.TextMatrix(tabel_last_deltaWjk.Rows - 1, 1) = deltaW0(1) '-------------------w0 akhir------------------------ tabel_Wjk_Akhir.TextMatrix(tabel_Wjk_Akhir.Rows 1, 1) = tabel_Wjk_Akhir.TextMatrix(tabel_Wjk.Rows - 1, 1) + deltaW0(1) '----------------------------------S_in--------------For j = 1 To Val(txt_hidden) S_in(j) = tabel_Wjk_Akhir.TextMatrix(j, 1) * Text3.Text Next j '-----------------------------------Sj---------------For j = 1 To Val(txt_hidden) S(j) = S_in(j) * Val(tabel_Z.TextMatrix(1, j - 1)) * (1 - Val(tabel_Z.TextMatrix(1, j - 1))) Next j '----------------------------------delta V ij------For i = 0 To tabel_Normalisasi(0).Cols - 1 For j = 1 To Val(txt_hidden) deltaVij(i, j) = Val(txt_alpha) * S(j) * Val(tabel_Normalisasi(q).TextMatrix(1, i)) + (Val(txt_momentum.Text) * Val(tabel_last_deltaVij.TextMatrix(i + 1, j))) last_deltaVij(i, j) = deltaVij(i, j)

43

tabel_last_deltaVij.TextMatrix(i + 1, j) = last_deltaVij(i, j) Next j Next i '--------------------------------delta V0--------For j = 1 To Val(txt_hidden) deltaV0(j) = Val(txt_alpha) * S(j) Next j '---------------------------------------W_jk akhir----For j = 1 To Val(txt_hidden) tabel_Wjk_Akhir.TextMatrix(j, 1) = tabel_Wjk_Akhir.TextMatrix(j, 1) + last_deltaWjk(j - 1, 1) Next j '----------------------------------V_ij akhir-------For i = 0 To tabel_Normalisasi(0).Cols - 1 For j = 1 To Val(txt_hidden) tabel_Vij_Akhir.TextMatrix(i + 1, j) = tabel_Vij_Akhir.TextMatrix(i + 1, j) + deltaVij(i, j) tabel_Vij_Akhir.TextMatrix(i + 1, j) = Format(tabel_Vij_Akhir.TextMatrix(i + 1, j), "0.0000000") Next j Next i '----------------------------------------'V0 akhirFor j = 1 To Val(txt_hidden) tabel_Vij_Akhir.TextMatrix(tabel_Vij_Akhir.Rows 1, j) = tabel_Vij_Akhir.TextMatrix(tabel_Vij_awal.Rows - 1, j) + deltaV0(j) Next j

44

Next q RMSE = Sqr(r) / Val(Txt_GbrInput.Text) ' TChart1.Series(0).Add RMSE, t, vbRed .Rows = t + 1 .ColWidth(1) = 2000 .ColWidth(0) = 500 .TextMatrix(t, 0) = t .TextMatrix(t, 1) = RMSE .TopRow = t End With If RMSE < Val(txt_error.Text) Then Exit Sub Next t DoEvents With tabel_error

'-------------------Nulis Wjk akhir yang lalu---------For j = 1 To Val(txt_hidden) tabel_Wjk_Akhir.TextMatrix(j, 1) = last_wjk(j, 1) tabel_Wjk_Akhir.TextMatrix(tabel_Wjk_Akhir.Rows 1, 1) = last_w0(1) Next j '------------------Nulis Vij akhir yang lalu----------For i = 0 To tabel_Normalisasi(0).Cols - 1 For j = 1 To Val(txt_hidden) tabel_Vij_Akhir.TextMatrix(i + 1, j) = last_vij(i, j) tabel_Vij_Akhir.TextMatrix(tabel_Vij_Akhir.Rows 1, j) = last_v0(j) Next j Next i

45

End Sub Private Sub Cmd_Simpan_Click() With CommonDialog1 .FileName = "" .Filter = "File Data TA (*.txt)|*.txt" .InitDir = "c:\AA\" .ShowSave Open .FileName For Output As #1 End With With tabel_Vij_Akhir For j = 1 To .Cols - 1 For i = 1 To .Rows - 1 Write #1, Val(.TextMatrix(i, j)) Next i Next j End With With tabel_Wjk_Akhir For j = 1 To .Rows - 1 Write #1, Val(.TextMatrix(j, 1)) Next j End With Write #1, Val(tabel_Y.TextMatrix(1, 0)) Close #1 End Sub Private Sub Command2_Click() fheight = 0 Form1.Height = 11520 step = 11520 Timer2.Interval = 10 End Sub

46

Private Sub Form_Load() On Error Resume Next SSTab1.Tab = 0 tabel_Wjk.ColWidth(0) = 500 tabel_Wjk_Akhir.ColWidth(0) = 500 tabel_Wjk_Akhir.ColWidth(1) = 2000 tabel_Yin.ColWidth(0) = 2000 tabel_Y.ColWidth(0) = 2000 tabel_Input(0).ColWidth(0) = 500 tabel_Input(1).ColWidth(0) = 500 tabel_Input(2).ColWidth(0) = 500 tabel_Input(3).ColWidth(0) = 500 tabel_Vij_awal.ColWidth(0) = 500 tabel_Vij_Akhir.ColWidth(0) = 500 fheight = 11520 Form1.Height = fheight step = 1000 Timer1.Interval = 10 End Sub Private Sub Timer1_Timer() Call Size1 If step = fheight Then Timer1.Enabled = False End If step = step + 20 Form1.Height = step End Sub Private Sub Timer2_Timer() Call size2 If step = fheight Then Timer2.Enabled = False End

47

End If step = step - 20 Form1.Height = step End Sub Private Sub txt_alpha_Change() Label30.Caption = txt_alpha Label39.Caption = txt_alpha End Sub Private Sub txt_epoch_Change() Label33.Caption = txt_epoch Label36.Caption = txt_epoch End Sub Private Sub txt_error_Change() Label32.Caption = txt_error Label37.Caption = txt_error End Sub Private Sub txt_hidden_Change() Label29.Caption = txt_hidden Label40.Caption = txt_hidden End Sub 'Private Sub txt_momentum_Change() 'Label31.Caption = txt_momentum 'Label38.Caption = txt_momentum 'End Sub Private Sub txt_target_Change() Label34.Caption = txt_target Label35.Caption = txt_target End Sub

48

Sub Size1() Form1.Top = (Screen.Height - Me.Height) / 2 End Sub Sub size2() Form1.Top = (Screen.Height - Me.Height) / 2 End Sub

Hasil tampilan program : 1. Halaman judul Untuk menjalankan program, klok button ok.

Setelah klik button ok, inputkan nilai-nilai yang akan dicari :

49

2.

Input gambar Pada halaman input gambar, inputkan sampel gambar tahu kuning yang akan di deteksi. Setelah gambar diinputkan, akan muncul nilai pixel dari gambar tersebut. Karena di awal menggunakan hidden layer 4, maka gambar yang diinputkan adalah 4.

3.

Training Pada proses training, klik button random untuk memulai training nilai dan gambar yang telah diinputkan.

50

4.

Hasil training

5.

Testing Untuk melakukan testing, pilih jenis data dan inputkan gambar yang akan di testing. Pada contoh dibawah ini jenis data yang dipilih adalah V1 dan gambar yang di inputkan adalah gambar tahu kuning alami. Setelah dilakukan testing didapat hasil error -0,34408379 dan hasil kesimpulannya adalah tahu kuning alami