Skip to content

Commit

Permalink
fix an error when loading double precision model file
Browse files Browse the repository at this point in the history
  • Loading branch information
shijiashuai committed Feb 20, 2019
1 parent 7b6b743 commit 6062b4f
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/thundersvm/model/svmmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,12 @@ void SvmModel::load_from_file(string path) {
string tuple;
while (ss >> tuple) {
sv.back().emplace_back(0, 0);
//todo use streaming operator >> here to avoid ifdef
#ifdef USE_DOUBLE
CHECK_EQ(sscanf(tuple.c_str(), "%d:%lf", &sv.back().back().index, &sv.back().back().value), 2)
#else
CHECK_EQ(sscanf(tuple.c_str(), "%d:%f", &sv.back().back().index, &sv.back().back().value), 2)
#endif
<< "error when loading model file";
};
}
Expand Down Expand Up @@ -368,4 +373,4 @@ void SvmModel::get_param(char* kernel_type, int* degree, float* gamma, float* co
*gamma = param.gamma;
*coef0 = param.coef0;
*probability = param.probability;
}
}

0 comments on commit 6062b4f

Please sign in to comment.