-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhybrid_nn_Classification.m
64 lines (63 loc) · 2.57 KB
/
hybrid_nn_Classification.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
function [Category,Category_cost,Category_performance,Category_output,Category_error,Emotion,Emotion_cost,Emotion_performance ,Emotions_output,Emotion_error]=hybrid_nn_Classification(Hybrid_Features,wav_file)
MFile= load('hybridmodels'); File= load('speech');
%Tr_categories=MFile.NNTr_categories;
%Tr_emotions=MFile.NNTr_emotions;
[rn,col]=find(strcmp(File.FilePath,wav_file));
targets1=transpose(File.categories_nn(col,:));
targets2=transpose(File.emotions_nn(col,:));
%==================Speech Disorder======================================%
% Test the Network
Features=transpose(Hybrid_Features);
Category_output=MFile.HybridNNStruct_categories(Features);
Category_errors = gsubtract(targets1,Category_output);
Category_performance = perform(MFile.HybridNNStruct_categories,targets1,Category_output);
%Category_performance= max([performance1,performance2]);
Category_error=min(Category_errors);
A=max(Category_output);
if A==Category_output(1)
Category={'Normal'};
Category_cost=[1,0];
else
Category={'Special'};
Category_cost=[0,1];
end
% Plots
% Uncomment these lines to enable various plots.
% figure, plotperform(tr)
% figure, plottrainstate(tr)
%figure, plotconfusion(targets1,Category_output)
%figure, ploterrhist(Category_errors)
%Categories_errors = gsubtract(targets,frequency_categories_outputs);
%Categories_performance = perform(MFile.NNStruct_frequency_categories,targets,frequency_categories_outputs);
%==================Speech Emotions======================================%
Emotions_output=MFile.HybridNNStruct_emotions(Features);
%frequency_errors = gsubtract(targets,frequency_emotions_outputs);
%frequency_performance = perform(MFile.NNStruct_frequency_emotions,targets,frequency_emotions_outputs);
Emotion_errors = gsubtract(targets2,Emotions_output);
Emotion_performance = perform(MFile.HybridNNStruct_emotions,targets2,Emotions_output);
%Emotion_performance= max([performance1,performance2,performance3,performance4]);
Emotion_error=min(Emotion_errors);
% Plots
% Uncomment these lines to enable various plots.
% figure, plotperform(tr)
%figure, plottrainstate(tr)
%figure, plotconfusion(targets2,Emotions_output)
%figure, ploterrhist(Emotion_errors)
A=max(Emotions_output);
if A==Emotions_output(1)
Emotion={'Angry'};
Emotion_cost=[1,0,0,0];
end
if A==Emotions_output(2)
Emotion={'Happy'};
Emotion_cost=[0,1,0,0];
end
if A==Emotions_output(3)
Emotion={'Neutral'};
Emotion_cost=[0,0,1,0];
end
if A==Emotions_output(4)
Emotion={'Sad'};
Emotion_cost=[0,0,0,1];
end
%figure, ploterrhist(errors);