Vous êtes sur la page 1sur 7

FAKULTAS TEKNIK

UNIVERSITAS NEGERI YOGYAKARTA


LAB SHEET SISTEM KENDALI LANJUT
Sem Genap Jaringan Syaraf Tiruan Sebagai
3 x 4 x 50 menit
2007/2008 pengenal Character/Huruf
SKL/EKA/EKA416/06 Rev : 01 Tgl : 1/03/2008 Hal 1 dari 7

1. Kompetensi :
Mahasiswa mempunyai pemahaman (dapat menjelaskan) Konsep
Pengendalian yang berbasis Jaringan Syaraf Tiruan.

2. Sub Kompetensi
Mahasiswa dapat memahami dan menjelaskan aplikasi jaringan syaraf Tiruan
sebagai pengenal karakter/Huruf.

3. Dasar Teori
A network is to be designed and trained to recognize the 26 letters of the alphabet.
An imaging system that digitizes each letter centered in the systems field of vision
is available. The result is that each letter is represented as a 5 by 7 grid of boolean
values. For example, here is the letter A:

However, the imaging system is not perfect and the letters may suffer from noise

The twenty-six 35-element input vectors are defined in the function prprob as a
matrix of input vectors called alphabet. The target vectors are also defined in this file
with a variable called targets. Each target vector is a 26-element vector with a 1 in
the position of the letter it represents, and 0s everywhere else. For example, the
letter A is to be represented by a 1 in the first element (as A is the first letter of the
alphabet), and 0s in elements two through twenty-six.
Dibuat oleh : Dilarang memperbanyak sebagian atau seluruh isi dokumen Diperiksa oleh :
tanpa ijin tertulis dari Fakultas Teknik Universitas Negeri Yogyakarta
FAKULTAS TEKNIK
UNIVERSITAS NEGERI YOGYAKARTA
LAB SHEET SISTEM KENDALI LANJUT
Sem Genap Jaringan Syaraf Tiruan Sebagai
3 x 4 x 50 menit
2007/2008 pengenal Character/Huruf
SKL/EKA/EKA416/06 Rev : 01 Tgl : 1/03/2008 Hal 2 dari 7

Neural Network
The network will receive the 35 boolean values as a 35-element input vector. It will
then be required to identify the letter by responding with a 26-element output vector.
The 26 elements of the output vector each represent a letter. To operate correctly the
network should respond with a 1 in the position of the letter being presented to the
network. All other values in the output vector should be 0.In addition, the network
should be able to handle noise. In practice the network will not receive a perfect
boolean vector as input. Specifically, the network should make as few mistakes as
possible when classifying vectors with noise of mean 0 and standard deviation of 0.2
or less.

Architecture
The neural network needs 35 inputs and 26 neurons in its output layer to identify the
letters. The network is a two-layer log-sigmoid/log-sigmoid network. The log-
sigmoid transfer function was picked because its output range (0 to 1) is perfect for
learning to output boolean values.

The hidden (first) layer has 10 neurons. This number was picked by guesswork and
experience. If the network has trouble learning, then neurons can be added to this
layer. The network is trained to output a 1 in the correct position of the output vector
and to fill the rest of the output vector with 0s. However, noisy input vectors may
result in the network not creating perfect 1s and 0s. After the network has been
trained the output will be passed through the competitive transfer function
compet. This makes sure that the output corresponding to the letter most like the
noisy input vector takes on a value of 1 and all others have a value of 0. The result
of this post-processing is the output that is actually used.

Initialization
The two layer network is created with newff.
S1 = 10; S2 = 26;
net = newff(minmax(P),[S1 S2],{'logsig' 'logsig'},'traingdx');

Training

Dibuat oleh : Dilarang memperbanyak sebagian atau seluruh isi dokumen Diperiksa oleh :
tanpa ijin tertulis dari Fakultas Teknik Universitas Negeri Yogyakarta
FAKULTAS TEKNIK
UNIVERSITAS NEGERI YOGYAKARTA
LAB SHEET SISTEM KENDALI LANJUT
Sem Genap Jaringan Syaraf Tiruan Sebagai
3 x 4 x 50 menit
2007/2008 pengenal Character/Huruf
SKL/EKA/EKA416/06 Rev : 01 Tgl : 1/03/2008 Hal 3 dari 7

To create a network that can handle noisy input vectors it is best to train the network
on both ideal and noisy vectors. To do this the network will first be trained on ideal
vectors until it has a low sum-squared error.
Then the network will be trained on 10 sets of ideal and noisy vectors. The network
is trained on two copies of the noise-free alphabet at the same time as it is trained on
noisy vectors. The two copies of the noise-free alphabet are used to maintain the
networks ability to classify ideal input vectors.
Unfortunately, after the training described above the network may have learned to
classify some difficult noisy vectors at the expense of properly classifying a noise
free vector. Therefore, the network will again be trained on just ideal vectors. This
ensures that the network will respond perfectly when presented with an ideal letter.
All training is done using backpropagation with both adaptive learning rate and
momentum with the function trainbpx.

4. Alat/Instrument/Aparatus/Bahan
Personal Computer (PC)
Software MATLAB

5. Keselamatan Kerja
Pastikan personal computer (PC) telah terinstall dengan baik
Jangan mengubah-ubah setting pada system operasi PC

6. Langkah Kerja
1. Buka matlab M-file. Buat dan fahami program dibawah, serta amati hasilnya!
%APPCR1 Character recognition.
% Mark Beale, 12-15-93
% Copyright (c) 1992-1998 by The MathWorks, Inc.
% $Revision: 1.12 $ $Date: 1998/06/11 16:07:38 $
clf;
figure(gcf)
echo on
% NEWFF - Inititializes feed-forward networks.
% TRAINGDX - Trains a feed-forward network with faster backpropagation.
% SIM - Simulates feed-forward networks.
% CHARACTER RECOGNITION:
% Using the above functions a feed-forward network is trained
% to recognize character bit maps, in the presence of noise.
pause % Strike any key to continue...

% DEFINING THE MODEL PROBLEM


% ==========================
Dibuat oleh : Dilarang memperbanyak sebagian atau seluruh isi dokumen Diperiksa oleh :
tanpa ijin tertulis dari Fakultas Teknik Universitas Negeri Yogyakarta
FAKULTAS TEKNIK
UNIVERSITAS NEGERI YOGYAKARTA
LAB SHEET SISTEM KENDALI LANJUT
Sem Genap Jaringan Syaraf Tiruan Sebagai
3 x 4 x 50 menit
2007/2008 pengenal Character/Huruf
SKL/EKA/EKA416/06 Rev : 01 Tgl : 1/03/2008 Hal 4 dari 7

% The script file PRPROB defines a matrix ALPHABET


% which contains the bit maps of the 26 letters of the
% alphabet.
% This file also defines target vectors TARGETS for
% each letter. Each target vector has 26 elements with
% all zeros, except for a single 1. A has a 1 in the
% first element, B in the second, etc.
[alphabet,targets] = prprob;
[R,Q] = size(alphabet);
[S2,Q] = size(targets);
pause % Strike any key to define the network...

% DEFINING THE NETWORK


% ====================
% The character recognition network will have 10
% neurons in its hidden layer (first layer).
S1 = 10;
net = newff(minmax(alphabet),[S1 S2],{'logsig' 'logsig'},'traingdx');
net.LW{2,1} = net.LW{2,1}*0.01;
net.b{2} = net.b{2}*0.01;
pause % Strike any key to train the network...

% TRAINING THE NETWORK WITHOUT NOISE


% ==================================
net.performFcn = 'sse'; % Sum-Squared Error performance function
net.trainParam.goal = 0.1; % Sum-squared error goal.
net.trainParam.show = 100; % Frequency of progress displays (in epochs).
net.trainParam.epochs = 5000; % Maximum number of epochs to train.
net.trainParam.mc = 0.95; % Momentum constant.
net.trainParam.min_grad = 1e-10; % gradient minimum
% Training begins...please wait...
P = alphabet;
T = targets;
[net,tr] = train(net,P,T);
% ...and finally finishes.
pause % Strike any key to train the network with noise...
% TRAINING THE NETWORK WITH NOISE
% ===============================
% A copy of the network will now be made. This copy will
% be trained with noisy examples of letters of the alphabet.
netn = net;
netn.trainParam.goal = 0.6; % Mean-squared error goal.
netn.trainParam.epochs = 300; % Maximum number of epochs to train.
% The network will be trained on 10 sets of noisy data.
pause % Strike any key to begin training...
% Training begins...please wait...
T = [targets targets targets targets];
for pass = 1:10
fprintf('Pas = %.0f\n',pass);
P = [alphabet, alphabet, ...
(alphabet + randn(R,Q)*0.1), ...
(alphabet + randn(R,Q)*0.2)];
Dibuat oleh : Dilarang memperbanyak sebagian atau seluruh isi dokumen Diperiksa oleh :
tanpa ijin tertulis dari Fakultas Teknik Universitas Negeri Yogyakarta
FAKULTAS TEKNIK
UNIVERSITAS NEGERI YOGYAKARTA
LAB SHEET SISTEM KENDALI LANJUT
Sem Genap Jaringan Syaraf Tiruan Sebagai
3 x 4 x 50 menit
2007/2008 pengenal Character/Huruf
SKL/EKA/EKA416/06 Rev : 01 Tgl : 1/03/2008 Hal 5 dari 7

[netn,tr] = train(netn,P,T);
echo off
end
echo on

% ...and finally finishes.

pause % Strike any key to finish training the network...

% TRAINING THE SECOND NETWORK WITHOUT NOISE


% =======================================
% The second network is now retrained without noise to
% insure that it correctly categorizes non-noizy letters.

netn.trainParam.goal = 0.1; % Mean-squared error goal.


netn.trainParam.epochs = 50; % Maximum number of epochs to train.
net.trainParam.show = 5; % Frequency of progress displays (in epochs).
% Training begins...please wait...
P = alphabet;
T = targets;
[netn,tr] = train(netn,P,T);
% ...and finally finishes.
pause % Strike any key to test the networks...

%---------------------------------------------
%----OK SEKARANG AKAN DI TEST HASILNYA--------
%----OK SEKARANG AKAN DI TEST HASILNYA--------
%---------------------------------------------
% Kita masukkan huruf yang mau di baca, diambil huruf A, B, C, D, E
pause % Strike any key to train the network with noise...
% Kita masukkan huruf yang mau di baca, diambil huruf A, B, C, D, E

letterA = [0 0 1 0 0 ...
0 1 0 1 0 ...
0 1 0 1 0 ...
1 0 0 0 1 ...
1 1 1 1 1 ...
1 0 0 0 1 ...
1 0 0 0 1 ]';

letterB = [1 1 1 1 0 ...
1 0 0 0 1 ...
1 0 0 0 1 ...
1 1 1 1 0 ...
1 0 0 0 1 ...
1 0 0 0 1 ...
1 1 1 1 0 ]';

letterC = [0 1 1 1 0 ...
1 0 0 0 1 ...
1 0 0 0 0 ...
Dibuat oleh : Dilarang memperbanyak sebagian atau seluruh isi dokumen Diperiksa oleh :
tanpa ijin tertulis dari Fakultas Teknik Universitas Negeri Yogyakarta
FAKULTAS TEKNIK
UNIVERSITAS NEGERI YOGYAKARTA
LAB SHEET SISTEM KENDALI LANJUT
Sem Genap Jaringan Syaraf Tiruan Sebagai
3 x 4 x 50 menit
2007/2008 pengenal Character/Huruf
SKL/EKA/EKA416/06 Rev : 01 Tgl : 1/03/2008 Hal 6 dari 7

1 0 0 0 0 ...
1 0 0 0 0 ...
1 0 0 0 1 ...
0 1 1 1 0 ]';

letterD = [1 1 1 1 0 ...
1 0 0 0 1 ...
1 0 0 0 1 ...
1 0 0 0 1 ...
1 0 0 0 1 ...
1 0 0 0 1 ...
1 1 1 1 0 ]';

letterE = [1 1 1 1 1 ...
1 0 0 0 0 ...
1 0 0 0 0 ...
1 1 1 1 0 ...
1 0 0 0 0 ...
1 0 0 0 0 ...
1 1 1 1 1 ]';

% Kelima huruf sudah dimasukkan sebagai data


% Dicoba jika hurufnya kena noise (tidak seperti aslinya), misal huruf C dab D
C_noise = [0 1 1 1 0 ...
1 1 1 0 1 ...
1 0 0 0 0 ...
1 0 0 0 0 ...
1 0 0 0 0 ...
1 0 0 0 1 ...
0 1 1 1 0 ]';

D_noise = [1 1 1 1 0 ...
1 0 0 0 1 ...
1 1 0 0 1 ...
1 0 0 0 1 ...
1 0 0 0 1 ...
1 0 0 0 1 ...
1 1 1 1 0 ]';

% Sekarang digunakan sebagai input dari jaringan yang telah dibuat


% TEST 1, baca huruf A
pause
P=letterA;
Huruf = sim(net,P)
Huruff = compet(Huruf)
%Terlihat hasilnya huruf A
pause
% TEST 2, baca huruf B
P=letterB;
Huruf = sim(net,P)
Huruff = compet(Huruf)
%Terlihat hasilnya huruf B
Dibuat oleh : Dilarang memperbanyak sebagian atau seluruh isi dokumen Diperiksa oleh :
tanpa ijin tertulis dari Fakultas Teknik Universitas Negeri Yogyakarta
FAKULTAS TEKNIK
UNIVERSITAS NEGERI YOGYAKARTA
LAB SHEET SISTEM KENDALI LANJUT
Sem Genap Jaringan Syaraf Tiruan Sebagai
3 x 4 x 50 menit
2007/2008 pengenal Character/Huruf
SKL/EKA/EKA416/06 Rev : 01 Tgl : 1/03/2008 Hal 7 dari 7

pause
% TEST 3, baca huruf C
P=letterC;
Huruf = sim(net,P)
Huruff = compet(Huruf)
%Terlihat hasilnya huruf C
% Silahkan ganti huruf yang mau di baca.
pause

% TEST 4, baca huruf C_noise


P=C_noise;
Huruf = sim(net,P)
Huruff = compet(Huruf)
%Terlihat hasilnya huruf C_noise masih dikenali sbg huruf C
pause
% TEST 5, baca huruf D_noise
P=D_noise;
Huruf = sim(net,P)
Huruff = compet(Huruf)
%Terlihat hasilnya huruf D_noise masih dikenali sbg huruf D

% Silahkan ganti huruf yang mau di baca.


pause

disp('SELESAI')

2. Jalankan program tersebut, Selanjutnya amati per langkahnya (per PAUSE).


Gambar dan perhatikan hasilnya

7. Bahan Diskusi
Amati setiap yang anda buat, diskusikan dengan teman anda.

8. Lampiran :
Sesuaikan dengan gambar yang diperoleh

Dibuat oleh : Dilarang memperbanyak sebagian atau seluruh isi dokumen Diperiksa oleh :
tanpa ijin tertulis dari Fakultas Teknik Universitas Negeri Yogyakarta

Vous aimerez peut-être aussi