blob: b15d2efe675dd151716f8e519d9eda9b3eaf7d0d (
plain)
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
|
#include"ranksvm.h"
#include"ranksvmtron.h"
#include<iostream>
#include<fstream>
#include<string>
using namespace Eigen;
int RSVM::saveModel(string fname){
std::ofstream fout(fname);
fout<<this->getName()<<endl;
fout<<this->model;
return 0;
}
static RSVM* RSVM::loadModel(string fname){
std::ifstream fin(fname);
std::string type;
int fsize;
fin>>type;
fin>>fsize;
RSVM* rsvm;
// TODO multiplex type
if (type=="TN")
RSVM = new RSVMTN();
rsvm->fsize=fsize;
VectorXd model;
fin>>model;
rsvm->setModel(model);
return rsvm;
}
int RSVM::setModel(Eigen::VectorXd model) {
if (model.cols()!=fsize)
LOG(FATAL) << "Feature size mismatch";;
this->model=model;
return 0;
}
|