-
Notifications
You must be signed in to change notification settings - Fork 9
/
fitnetEstTrajectory.m~
121 lines (88 loc) · 3 KB
/
fitnetEstTrajectory.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
% refined code
close all;
clear all;
if isempty(dir('./Data'))
mkdir Data
end
if isempty(dir('./Fig'))
mkdir Fig
end
% =================== global setting ============
nn.isRad = 0;
nn.isBayes = 0;
nn.hiddenLayerSize = [25 25 25];
Case.note = sprintf('snapshot & SNR');
Case.isSend = 0 % disable when debug
sig.caseID = 'test';
sig.geometry = 'UCA'
sig.isRand = 1;
sig.type = 'tone'
sig.mod = 'none'
sig.intf = 'none' % single tone
sig.theta = [58.6 26.7 26.7 36.7 48.6]./180*pi; % DoA
sig.P = [1 1 1 1 1];
sig.K = length(nonzeros(sig.P)); % num of source
sig.f_c = [ 0.55 0.65 0.75 0.85 0.45 ];
% sig.phi_c = [ 0 0 0 0 0];
sig.phi_c = [58.6 26.7 26.7 30.0 48.6]./180*pi; % DoA
sig.SNRdB = 5;
sig.N = 500; % snapshot
sig.M = 6; % num of Anntenna
sig.setN = [40 40];
target.ID = 1;
target.Para = 'theta';
tag = sig.caseID;
tagData = strcat(tag,'Data.mat');
if isempty(dir(tagData)) & isempty(dir(tagData))
[allData, rawData, Label, sig] = generateData2(sig,target);
else
disp('data found, load data ...');
load(strcat('./Data/',tagData));
load(strcat('./Data/',sig.caseID,'RawData.mat'));
load(strcat('./Data/',sig.caseID,'Label.mat'));
end
% ----- stack X ------
stackNum = 11;
allData = myStackData( allData, stackNum);
% ============== extract Label and Split Data====================
nn.trainRatio = 0.80;
Sizefull = length(allData(:,1));
trainSize = round(Sizefull*nn.trainRatio/100)*100;
% ------- extract Label -----
if strcmp(target.Para,'theta')
temp = reshape([Label.theta],[sig.K,Sizefull]);
elseif strcmp(target.Para,'phi')
temp = reshape([Label.phi],[sig.K,Sizefull]);
end
temp = temp';
Y = temp(:,target.ID); % 1st sig
% ------- split data -----
Xtrain = allData(1:trainSize,:)';
Ytrain = Y(1:trainSize,:)';
Xtest = allData(trainSize:Sizefull,:)';
Ytest = Y(trainSize:Sizefull,:)';
save(strcat('./Data/',sig.caseID,'Y.mat'), 'Y' );
save(strcat('./Data/',sig.caseID,'Xtrain.mat'),'Xtrain');
save(strcat('./Data/',sig.caseID,'Ytrain.mat'),'Ytrain');
% ======================= train ================================
[net, tr] = myTrain(nn, Xtrain, Ytrain);
% =================== test ============
% tInd = tr.testInd;
% predict = net(Xtrain(:, tInd));
% ground = Ytrain(tInd);
predict = net(Xtest);
ground = Ytest;
% =================== eval ============
predictPerformance = perform(net, ground, predict);
errors = abs(gsubtract(ground, predict));
mse = immse(ground, predict);
errM = mean(errors);
eerMdeg = errM*180/pi
RMSE = sqrt(mean((errors).^2));
RMSE = RMSE *180/pi
errVar = var(errors);
save(strcat('./Data/',sig.caseID,'errors.mat'),'errors');
save(strcat('./Data/',sig.caseID,'ground.mat'),'ground');
save(strcat('./Data/',sig.caseID,'predict.mat'),'predict');
% ======== save fig & send email =====s=======
myPlot(eerMdeg,RMSE,errors,ground,predict, sig, nn, Case, net, tr);