-
Notifications
You must be signed in to change notification settings - Fork 93
/
load_save_test.cxx
52 lines (41 loc) · 1.64 KB
/
load_save_test.cxx
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
#include <string>
#include <vector>
#include <map>
#include <image_train.hpp>
using namespace std;
int main() {
int classes = 10;
int batch_size = 4;
vector<string> networks={"lenet","alexnet","googlenet","inception_bn","resnet","vgg"};
for(string& network : networks) {
string md5_first;
{
ImageTrain imageTrain = ImageTrain();
imageTrain.buildNet(classes,batch_size,(char*)network.c_str());
imageTrain.saveModel("/tmp/model");
imageTrain.saveParam("/tmp/params");
assert(std::system("md5sum /tmp/model /tmp/params > /tmp/log.txt")==0);
std::ifstream ifs("/tmp/log.txt");
md5_first=string((std::istreambuf_iterator<char>(ifs)), std::istreambuf_iterator<char>());
}
string md5_second;
{
ImageTrain imageTrain = ImageTrain();
imageTrain.loadModel("/tmp/model");
imageTrain.setOptimizer(classes,batch_size);
imageTrain.loadParam("/tmp/params");
imageTrain.saveModel("/tmp/model");
imageTrain.saveParam("/tmp/params");
assert(std::system("md5sum /tmp/model /tmp/params > /tmp/log.txt")==0);
std::ifstream ifs("/tmp/log.txt");
md5_second=string((std::istreambuf_iterator<char>(ifs)), std::istreambuf_iterator<char>());
}
std::cout << "\n" << network << " : ";
if (md5_first.compare(md5_second)!=0)
std::cout << "FAIL" << std::endl;
else
std::cout << "PASS" << std::endl;
std::cout << md5_first << "\n" << md5_second << "\n";
}
MXNotifyShutdown();
}