Upload
natheer-ataya-abu-jarir
View
218
Download
0
Tags:
Embed Size (px)
DESCRIPTION
Third Assignment: Use all your data (F0, F1, F2, F3, and F4) for speaker classification (M, W, or C) by using Multi-layer Forward Neural Network with backpropagation training. Fourth Assignment: Use all data to classify 5 classes of vowels as following: 1st class: 1st, 2nd, and 3rd columns. 2nd class: 4th and 5th columns. 3rd class: 6th and 7th columns. 4th class: 8th, 9th, and 10th columns. 5th class: 11th and 12th columns. by using Multi-layer Forward Neural Network with backpropagation training.
Citation preview
بسم ميحرلا نمحرلا هللا
Islamic University – Gaza
Faculty of Engineering
Department of Computer Engineering
Neural Networks
Assignment # 3 +4
Prepared By:
Natheer A. Abu Jarir 120120820
Submitted to:
Associate Professor: Mohammed Alhanjouri
2014
Third Assignment :
Use all your data (F0, F1, F2, F3, and F4) for speaker classification
(M, W, or C) by using Multi-layer Forward Neural Network with
backpropagation training.
Matlab Code Neural Network :
close all, clear all, clc, format compact
% loading data
M = [138 135 129 127 123 123 121 129 133
143 133 130
342 427 476 580 588 768 652 497
269 378 623 474
2322 2034 2089 1799 1952 1333 997 910
1122 997 1200 1379
3000 2684 2691 2605 2601 2522 2538 2459
2434 2343 2550 1710
3657 3616 3649 3677 3624 3687 3486 3384
3400 3357 3557 3334 ];
W = [ 227 224 219 214 215 215 210 217 230
235 218 217
437 483 536 731 669 936 781 555
519 459 753 523
2761 2365 2530 2058 2349 1551 1136 1035
1225 1105 1426 1588
3372 3053 3047 2979 2972 2815 2824 2828
2827 2735 2933 1929
4352 4334 4319 4294 4290 4299 3923 3927
4052 4115 4092 3914 ];
C = [ 246 241 237 230 228 229 225 236 243
249 236 237
452 511 564 749 717 1002 803 597
568 494 749 586
3081 2552 2656 2267 2501 1688 1210 1137
1490 1345 1546 1719
3702 3403 3323 3310 3289 2950 2982 2987
3072 3988 3145 2143
4572 4575 4422 4671 4409 4307 3919 4167
4328 4276 4320 3788];
% define inputs (combine samples from all four classes)
P=[M W C];
% define output coding for classes
a = [+1 +1]';
b = [+1 -1]';
c = [-1 +1]';
% define targets
T = [repmat(a,1,length(man)) repmat(b,1,length(woman)) ...
repmat(c,1,length(child))];
%# create ANN of one hidden layer with 7 nodes
net = feedforwardnet(10);
%# set params
net.layers{1}.transferFcn = 'logsig';
net.trainFcn = 'trainscg'; %# training function
net.trainParam.epochs = 5000; %# max number of iterations
net.trainParam.lr =.1; %# learning rate
net.performFcn = 'mse'; %# mean-squared error function
net.divideFcn = 'dividerand';
%# how to divide data
net.divideParam.trainRatio = 70/100; %# training set
net.divideParam.valRatio = 15/100; %# validation set
net.divideParam.testRatio = 30/100; %# testing set
% %
%# training
net = init(net);
[net,tr] = train(net, P,T);
%# testing
y_hat = net(ptest);
perf = perform(net, T, y_hat);
err = gsubtract(T, y_hat);
Results:
Fourth Assignment:
Use all data to classify 5 classes of vowels as following:
1st class: 1st, 2nd, and 3rd columns.
2nd class: 4th and 5th columns.
3rd class: 6th and 7th columns.
4th class: 8th, 9th, and 10th columns.
5th class: 11th and 12th columns.
by using Multi-layer Forward Neural Network with backpropagation
training.
Matlab Code Neural Network :
close all, clear all, clc, format compact
class1 = [ 138 135 129
227 224 219
246 241 237
342 427 476
437 483 536
452 511 564
2322 2034 2089
2761 2365 2530
3081 2552 2656
3000 2684 2691
3372 3053 3047
3702 3403 3323
3657 3616 3649
4352 4334 4319
4572 4575 4422 ];
class2 = [ 127 123
214 215
230 228
580 588
731 669
749 717
1799 1952
2058 2349
2267 2501
2605 2601
2979 2972
3310 3289
3677 3624
4294 4290
4671 4409 ];
class3 = [ 123 121
215 210
229 225
768 652
936 781
1002 803
1333 997
1551 1136
1688 1210
2522 2538
2815 2824
2950 2982
3687 3486
4299 3923
4307 3919];
class4 = [ 129 133 143
217 230 235
236 243 249
497 269 378
555 519 459
597 568 494
910 1122 997
1035 1225 1105
1137 1490 1345
2459 2434 2343
2828 2827 2735
2987 3072 3988
3384 3400 3357
3927 4052 4115
4167 4328 4276];
class5 = [ 133 130
218 217
236 237
623 474
753 523
749 586
1200 1379
1426 1588
1546 1719
2550 1710
2933 1929
3145 2143
3557 3334
4092 3914
4320 3788];
% define inputs (combine samples from all four classes)
P=[class1 class2 class3 class4 class5];
% define output coding for classes
a = [+1 +1 +1]';
b = [+1 -1 +1]';
c = [-1 +1 +1]';
d = [+1 -1 -1]';
e = [-1 +1 -1]';
% define targets
T = [repmat(a,1,length(class1)) repmat(b,1,length(class2)) ...
repmat(c,1,length(class3)) repmat(d,1,length(class4)) ...
repmat(e,1,length(class5))];
%# create ANN of one hidden layer with 7 nodes
net = feedforwardnet(10);
%# set params
net.layers{1}.transferFcn = 'logsig';
net.layers{2}.transferFcn = 'purelin';
net.trainFcn = 'trainscg'; %# training function
net.trainParam.epochs = 5000; %# max number of iterations
net.trainParam.lr =.1; %# learning rate
net.performFcn = 'mse'; %# mean-squared error function
net.divideFcn = 'dividerand';
%# how to divide data
net.divideParam.trainRatio = 70/100; %# training set
net.divideParam.valRatio = 15/100; %# validation set
net.divideParam.testRatio = 30/100; %# testing set
%# training
net = init(net);
[net,tr] = train(net, P,T);
%# testing
y_hat = net(ptest);
perf = perform(net, T, y_hat);
err = gsubtract(T, y_hat);
Results:
References:
[1] Neural Networks: MATLAB examples.
[2] http://www.mathworks.com/help/nnet/index.html.