-
Notifications
You must be signed in to change notification settings - Fork 6
/
main.cpp
66 lines (48 loc) · 1.85 KB
/
main.cpp
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
#include "typedef.h"
#include "util.h"
#include "test.h"
#include<ctime>
using namespace std;
extern long long lengthData,numMutilBool,numMutil;
int main() {
int flag=0;
clock_t startClock, endClock;
startClock = clock(); //程序开始计时
initMPC();
cout << "---随机数传输完成---" << endl;
readData(flag);
cout << "---密文数据读取完成---" << endl;
selectTrainSet(40);
if (1) {
Init(1);
cout << "---权重初始化完成---" << endl;
train();
endClock = clock(); //程序结束用时
double endtime = (double) (endClock - startClock) / CLOCKS_PER_SEC;
long long onCom=Online();
long long offCom=Offline();
cout <<"Online comm: " <<onCom<<" MB"<<endl;
cout <<"Offline comm: " <<offCom<<" MB"<<endl;
cout << "Training time: " << endtime / 120.0+ onCom/(dataRate*60.0)<< " minutes" << endl;
cout << "Offline Time: " << offCom/(dataRate*60.0)<< " minutes" << endl;
writeModel(flag);
cout << "---写入模型成功---" << endl;
}
else{
readModel(flag);
cout << "---密文模型读取完成---" << endl;
Init(0);
cout << "---初始化完成---" << endl;
double accuracy = testData();
endClock = clock(); //程序结束用时
cout << "---准确率:" << accuracy << "---" << endl;
double endtime = (double) (endClock - startClock) / CLOCKS_PER_SEC;
long long onCom=Online();
long long offCom=Offline();
cout <<"Online comm: " <<onCom<<" MB"<<endl;
cout <<"Offline comm: " <<offCom<<" MB"<<endl;
cout << "Inference time: " << endtime / 120.0+ onCom/(dataRate*60.0)<< " minutes" << endl;
cout << "Offline Time: " << offCom/(dataRate*60.0)<< " minutes" << endl;
}
return 0;
}