Skip to content

Commit f494023

Browse files
committed
add try-catch in main() #31
1 parent 8c37dc3 commit f494023

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

src/thundersvm/thundersvm-predict.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,20 @@ int main(int argc, char **argv) {
2727
std::shared_ptr<SvmModel> model;
2828
std::shared_ptr<Metric> metric;
2929
if (svm_type == "c_svc") {
30-
model = new SVC();
31-
metric = new Accuracy();
30+
model.reset(new SVC());
31+
metric.reset(new Accuracy());
3232
} else if (svm_type == "nu_svc") {
33-
model = new NuSVC();
34-
metric = new Accuracy();
33+
model.reset(new NuSVC());
34+
metric.reset(new Accuracy());
3535
} else if (svm_type == "one_class") {
36-
model = new OneClassSVC();
36+
model.reset(new OneClassSVC());
3737
//todo determine a metric
3838
} else if (svm_type == "epsilon_svr") {
39-
model = new SVR();
40-
metric = new MSE();
39+
model.reset(new SVR());
40+
metric.reset(new MSE());
4141
} else if (svm_type == "nu_svr") {
42-
model = new NuSVR();
43-
metric = new MSE();
42+
model.reset(new NuSVR());
43+
metric.reset(new MSE());
4444
}
4545

4646
#ifdef USE_CUDA

src/thundersvm/thundersvm-train.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,19 @@ int main(int argc, char **argv) {
2222
std::shared_ptr<SvmModel> model;
2323
switch (parser.param_cmd.svm_type) {
2424
case SvmParam::C_SVC:
25-
model = new SVC();
25+
model.reset(new SVC());
2626
break;
2727
case SvmParam::NU_SVC:
28-
model = new NuSVC();
28+
model.reset(new NuSVC());
2929
break;
3030
case SvmParam::ONE_CLASS:
31-
model = new OneClassSVC();
31+
model.reset(new OneClassSVC());
3232
break;
3333
case SvmParam::EPSILON_SVR:
34-
model = new SVR();
34+
model.reset(new SVR());
3535
break;
3636
case SvmParam::NU_SVR:
37-
model = new NuSVR();
37+
model.reset(new NuSVR());
3838
break;
3939
}
4040

@@ -71,12 +71,12 @@ int main(int argc, char **argv) {
7171
switch (parser.param_cmd.svm_type) {
7272
case SvmParam::C_SVC:
7373
case SvmParam::NU_SVC: {
74-
metric = new Accuracy();
74+
metric.reset(new Accuracy());
7575
break;
7676
}
7777
case SvmParam::EPSILON_SVR:
7878
case SvmParam::NU_SVR: {
79-
metric = new MSE();
79+
metric.reset(new MSE());
8080
break;
8181
}
8282
case SvmParam::ONE_CLASS: {

0 commit comments

Comments
 (0)