-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtrain.cpp
563 lines (496 loc) · 21.9 KB
/
train.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
#include <GRT.h>
#include <iostream>
#include <stdio.h>
#include "cmdline.h"
#include "libgrt_util.h"
using namespace GRT;
using namespace std;
Classifier *apply_cmdline_args(string,cmdline::parser&,int,string&);
string list_classifiers();
InfoLog info;
int main(int argc, const char *argv[])
{
Classifier *classifier = NULL;
string input_file = "-";
cmdline::parser c;
c.add<int> ("verbose", 'v', "verbosity level: 0-4", false, 1);
c.add ("help", 'h', "print this message");
c.add<string>("output", 'o', "store trained classifier in file", false);
c.add<string>("trainset",'n', "split the trainig set, either no, random, or k-fold split, defaults to no split.", false, "-1");
c.footer ("<classifier> [input-data]...");
/* parse common arguments */
bool parse_ok = c.parse(argc, argv, false) && !c.exist("help");
set_verbosity(c.get<int>("verbose"));
/* got a trainable classifier? */
string str_classifier = c.rest().size() > 0 ? c.rest()[0] : "list";
if (str_classifier == "list") {
cout << c.usage() << endl;
cout << list_classifiers();
return 0;
}
/* add the classifier specific arguments */
classifier = apply_cmdline_args(str_classifier,c,1,input_file);
if (!parse_ok) {
cerr << c.usage() << endl << c.error() << endl;
return -1;
}
if (classifier == NULL) {
cerr << "error: unable to load/create algorithm: " << str_classifier << endl;
return -1;
}
/* check if we can open the output file */
ofstream test(c.get<string>("output"), ios_base::out);
ostream &output = c.exist("output") ? test : cout;
if (c.exist("output") && !test.good()) {
cerr << c.usage() << endl << "unable to open \"" << c.get<string>("output") << "\" as output" << endl;
return -1;
}
/* do we read from a file or stdin? */
ifstream fin; fin.open(input_file);
istream &in = input_file=="-" ? cin : fin;
if (!in.good()) {
cerr << "unable to open input file " << input_file << endl;
return -1;
}
/* now start to read input samples */
CsvIOSample io( classifier->getTimeseriesCompatible() ? "timeseries" : "classification" );
CollectDataset dataset;
/* get all possible modes for training set selection */
char *endptr = NULL,
*file = c.get<string>("trainset").c_str();
double ratio = strtod(file, &endptr);
bool isfile = (endptr-file) - strlen(file) != 0;
int32_t /* parse x.yy into integral and fractional part */
integral = strtoul(file, &endptr, 10),
fraction = *endptr=='.' ? strtoul(endptr+1, NULL, 10) : -1;
// special case for a ratio of 100%
if (ratio == 1) ratio = -1;
// do some sanity checks on the arguments
if (!isfile && ratio >= 0) {
// k-fold specification
if ( fraction < 0 ) {
cerr << "no fold number given, specify with k.x or use a ratio (0,1] for random split" << endl;
return -1;
}
if ( integral >= 1 && fraction >= integral ) {
cerr << "fold number (" << fraction << ") must be less than number"
" of folds (" << integral << ")" << endl;
return -1;
}
if (ratio >= 1 && fraction < 0) {
cerr << "either -n must be less than one to select a random split "
"or given as k.x where k is the number of folds, and x the fold to "
"select " << endl;
return -1;
}
}
/* per default we read from the main inputstream */
ifstream tif; istream &tin = isfile ? tif : in;
if (isfile) tif.open(file);
/* now read the input file completely */
while ( tin >> io ) {
bool ok=false; csvio_dispatch(io, ok=dataset.add, io.labelset);
if (!ok) {
cerr << "error at line " << io.linenum << endl;
exit(-1);
}
}
/* empty input? */
if (dataset.size() == 0)
return 0;
/* generate training sets if any are required, which is either a timeseries
* or classification data */
TimeSeriesClassificationData t_test, t_training;
ClassificationData c_test, c_training;
/* There is a case for polymorphism in GRT here */
switch(io.type) {
case TIMESERIES:
if (isfile || ratio <= 0) // no split or file
t_training = dataset.t_data;
else if (ratio < 1) { // random split
t_test = dataset.t_data.partition( ratio*100, true );
t_training = dataset.t_data;
}
else if (ratio >= 1) { // k-fold
if (!dataset.t_data.splitDataIntoKFolds( integral, false, false )) {
cerr << "unable to split data" << endl;
return -1;
}
t_test = dataset.t_data.getTestFoldData( fraction );
t_training = dataset.t_data.getTrainingFoldData( fraction );
}
else {
cerr << "unknown train set specification" << endl;
return -1;
}
break;
case CLASSIFICATION:
if (isfile || ratio <= 0) // no split or file
c_training = dataset.c_data;
else if (ratio < 1) { // random split
c_test = dataset.c_data.partition( ratio*100, true );
c_training = dataset.c_data;
}
else if (ratio >= 1) { // k-fold
if (!dataset.c_data.splitDataIntoKFolds( integral, false, false )) {
cerr << "unable to split data" << endl;
return -1;
}
c_test = dataset.c_data.getTestFoldData( fraction );
c_training = dataset.c_data.getTrainingFoldData( fraction );
}
else {
cerr << "unknown train set specification" << endl;
return -1;
}
break;
default:
cerr << "io type not implemented" << endl;
return -1;
}
info << dataset.getStatsAsString() << endl;
/* train and save classifier */
bool ok = false;
switch(io.type) {
case TIMESERIES:
ok = classifier->train(t_training);
break;
case CLASSIFICATION:
ok = classifier->train(c_training);
break;
}
if (!ok) {
cerr << "training failed" << endl;
return -1;
}
/* propagate the classlabel names also */
for (size_t i=!io.has_NULL_label; i<io.labelset.size(); i++) {
classifier->setClassNameForLabel(i, io.labelset[i]);
}
if (!classifier->saveModelToFile(output)){
cerr << "saving to " << c.get<string>("output") << " failed" << endl;
return -1;
}
if (!c.exist("output"))
cout << endl; // mark the end of the classifier if piping
else
test.close();
// The classifier is trained, we now pass-through data, which is different
// depending on the mode that has been selected.
if (isfile) {
string line;
while (getline(in, line))
cout << line << endl;
} else if (ratio > 0) { // random split
bool first = true;
switch(io.type) {
case TIMESERIES:
for (auto sample : t_test.getClassificationData()) {
string label = t_test.getClassNameForCorrespondingClassLabel( sample.getClassLabel() );
MatrixFloat &matrix = sample.getData();
if (first) first = false;
else cout << endl;
for (int i=0; i<matrix.getNumRows(); i++) {
cout << label;
for (int j=0; j<matrix.getNumCols(); j++)
cout << " " << matrix[i][j];
cout << endl;
}
}
break;
case CLASSIFICATION:
for (auto sample : c_test.getClassificationData()) {
string label = c_test.getClassNameForCorrespondingClassLabel( sample.getClassLabel() );
cout << label;
for (auto val : sample.getSample())
cout << "\t" << val;
cout << endl;
}
break;
default:
cerr << "unknown IO type" << endl;
return -1;
}
}
return 0;
}
string list_classifiers() {
vector<string> exclude = {"HMM", "BAG", "SwipeDetector"};
vector<string> names = Classifier::getRegisteredClassifiers();
stringstream ss;
string name;
cout << "HMM (timeseries)" << endl;
cout << "cHMM (timeseries)" << endl;
for (auto name : names) {
if (find(exclude.begin(),exclude.end(),name)!=exclude.end())
continue;
Classifier *c = Classifier::createInstanceFromString(name);
if (c->getTimeseriesCompatible())
ss << name << " (timeseries" << (c->getSupportsNullRejection() ? ",null rejection)" : ")") << endl;
}
for (auto name : names) {
Classifier *c = Classifier::createInstanceFromString(name);
if (find(exclude.begin(),exclude.end(),name)!=exclude.end())
continue;
if (!c->getTimeseriesCompatible())
ss << name << (c->getSupportsNullRejection() ? " (null rejection)" : "") << endl;
}
return ss.str();
}
#define checkedarg(func, type, name) if(!func(p.get<type>(name))) { cerr << "invalid value for" << name << " " << p.get<type>(name) << endl; return NULL; }
Classifier *apply_cmdline_args(string name,cmdline::parser& c,int num_dimensions,string &input_file)
{
cmdline::parser p;
Classifier *o = NULL;
if ( "HMM" == name ) {
# define HMM_TYPE "ergodic", "leftright"
p.add<string>("hmmtype", 'T', "either 'ergodic' or 'leftright' (default: ergodic)", false, "leftright", cmdline::oneof<string>(HMM_TYPE));
p.add<double>("delta", 0, "delta for leftright model, default: 1", false, 1);
p.add<int> ("num-states", 'S', "number of states", false, 10);
p.add<int> ("num-symbols", 'N', "number of symbols", false, 20);
p.add<int> ("max-epochs", 0, "maximum number of epochs during training", false, 1000);
p.add<float> ("min-change", 0, "minimum change before abortion", false, 1.0e-5);
} else if ( "cHMM" == name ) {
p.add<string>("hmmtype", 'T', "either 'ergodic' or 'leftright' (default: ergodic)", false, "ergodic", cmdline::oneof<string>(HMM_TYPE));
p.add<int> ("comitteesize", 0, "number of models used for prediction, default: 10", false, 10);
p.add<double>("delta", 0, "delta for leftright model, default: 1", false, 1);
p.add<int> ("downsample", 0, "downsample factor, default: 5", false, 5);
} else if ( "KNN" == name ) {
# define KNN_DISTANCE "euclidean", "cosine", "manhattan"
p.add<string>("distance", 'D', "either 'euclidean', 'cosine' or 'manhatten'", false, "euclidean", cmdline::oneof<string>(KNN_DISTANCE));
p.add<double>("null-coefficient", 'N', "delta for NULL-class rejection, 0.0 means off", false, 0.0);
p.add<int> ("K-neighbors", 'K', "number of neighbors used in classification (if 0 search for optimum)", false, 0);
p.add<int> ("min-K", 0, "only used during search", false, 2);
p.add<int> ("max-K", 0, "only used during search", false, 20);
} else if ( "DTW" == name ) {
# define DTW_REJECTION_MODE "template", "class", "template_class"
p.add<double>("null-coefficient", 'N', "multiplier for NULL-class rejection, 0.0 means off", false, 0.0);
p.add<double>("null-threshold", 'T', "likelihood threshold for CLASS rejection modes, 0.0 means off", false, 0.0);
p.add<string>("rejection-mode", 'R', "NULL-class rejection mode", false, "template", cmdline::oneof<string>(DTW_REJECTION_MODE));
p.add<double>("warping-radius", 'W', "limit the warping to this radius (0 means disabled, 1 is maximum)", false, 0, cmdline::range(0.,1.));
} else if ( "FiniteStateMachine" == name ) {
p.add<int> ("num-particles", 'N', "number of particles", false, 200);
p.add<int> ("num-clusters", 'M', "number of clusters per state", false, 10);
p.add<double>("transition-smoothing", 'T', "state transition smoothing", false, 0);
p.add<double>("measurement-noise", 'S', "measurement noise", false, 10.);
} else if ( "ParticleClassifier" == name ) {
p.add<int> ("num-particles", 'N', "number of particles", false, 200);
p.add<double>("measurement-noise", 'S', "measurement noise", false, 10.);
p.add<double>("transition-sigma", 'T', "transition sigma", false, 0.005);
p.add<double>("phase-sigma", 'P', "phase sigma", false, 0.1);
p.add<double>("velocity-sigma", 'V', "velocity sigma", false, 0.01);
} else if ( "RandomForests" == name) {
# define RF_TRAINING "random", "iterative"
p.add<int> ("forest-size", 'N', "number of trees in the forest", false, 10);
p.add<int> ("num-split", 'S', "number of split to search", false, 100);
p.add<int> ("num-samples", 'M', "number of samples for non-leaf nodes", false, 5);
p.add<int> ("max-depth", 'D', "maximum depth of the tree", false, 10);
p.add<string>("training-mode", 'T', "training mode", false, "random", cmdline::oneof<string>(RF_TRAINING));
p.add ("remove-features", 'F', "remove features at each split");
} else if ( "SVM" == name ) {
# define SVM_KERNELS "linear","poly","rbf","sigmoid","precomputed"
# define SVM_TYPES "C_SVC","NU_SVC","ONE_CLASS","EPSILON_SVR","NU_SVR"
p.add<string>("kernel", 'K', "kernel type", false, "linear", cmdline::oneof<string>(SVM_KERNELS));
p.add<string>("type", 'T', "svm type", false,"C_SVC", cmdline::oneof<string>(SVM_TYPES));
p.add<double>("gamma", 'G', "set to 0. to auto-calculate", false, 0, cmdline::range(0,1));
p.add<int> ("degree", 'D', "SVM degree parameter", false, 3);
p.add<double>("coef0", 'O', "SVM coef0 parameter", false, 0);
p.add<double>("nu", 'M', "SVM nu parameter", false, 0.5);
p.add<double>("C", 'C', "SVM C parameter", false, 1);
} else if ( "ANBC" == name ) {
p.add<double>("null-coef", 'N', "null rejection coefficient, default: 0 (not used)", false, 0);
} else if ( "GMM" == name ) {
p.add<int> ("mixtures", 'M', "num of mixtures", false, 3);
p.add<double>("null-coef", 'N', "null rejection coefficient, default: 0 (not used)", false, 0);
p.add<int> ("max-iterations", 'I', "num of iterations", false, 10000);
p.add<double>("epsilon", 'E', "minimum change between iteration", false, .1);
} else if ( "AdaBoost" == name ) {
# define ADABOOST_TYPES "max_positive", "max"
# define ADABOOST_CLASS "DS","RBF"
p.add<double>("null-coef", 'N', "null rejection coefficient, default: 0 (not used)", false, 0);
p.add<int> ("max-iterations", 'I', "num of iterations", false, 10000);
p.add<string>("prediction-type", 'T', "predicition method" , false,"MAX_POSITIVE_VALUE", cmdline::oneof<string>(ADABOOST_TYPES));
p.add<string>("weak-classifier", 'C', "weak classifier to be boosted", false, "DS", cmdline::oneof<string>(ADABOOST_CLASS));
p.add<int> ("num-steps", 'S', "(RBF/DS) number of steps for rbf", false, 100);
p.add<double>("pos-tresh", 'P', "(RBF) positive classification treshhold", false, .9);
p.add<double>("min-alpha", 'L', "(RBF) lower alpha threshold", false, .001);
p.add<double>("max-alpha", 'H', "(RBF) higher alpha threshold", false, 1);
} else if ( "DecisionTree" == name ) {
# define DT_TRAINING "iterative", "random"
p.add<int> ("min-samples-per-node", 'M', "minimum number of samples per node before becoming a lead node", false, 5);
p.add<int> ("max-depth", 'D', "maximum depth of the tree", false, 10);
p.add ("remove-features", 'F', "remove features at each split");
p.add<string>("training-mode", 'T', "training mode", false, "iterative", cmdline::oneof<string>(DT_TRAINING));
p.add<int> ("num-split", 'S', "number of splitting nodes to search", false, 100);
} else if ( "MinDist" == name ) {
p.add<double>("null-coef", 'N', "null rejection coefficient", false, 10);
p.add<int>("num-clusters", 'C', "number of clusters", false, 10);
} else if ( "Softmax" == name ) {
p.add<double>("learning-rate", 'R', "learning rate for training", false, .1);
p.add<double>("min-change", 'C', "minimum change between steps", false, 1e-10);
p.add<double>("max-epochs", 'E', "maximum number of epochs", false, 1000);
}
if (c.exist("help")) {
cerr << c.usage() << endl << name << " options:" << endl << p.str_options();
exit(0);
}
if (!p.parse(c.rest())) {
cerr << c.usage() << endl << name << " options:" << endl << p.str_options() << endl << p.error() << endl;
exit(-1);
}
if ( "HMM" == name ) {
vector<string> list = {HMM_TYPE};
HMM *h = new HMM(
/* hmmtype */ HMM_DISCRETE,
/* hmmodel */ find(list.begin(), list.end(), p.get<string>("hmmtype")) - list.begin(),
/* delta */ p.get<double>("delta"),
/* scaling */ false,
/* useNull */ true);
checkedarg(h->setNumStates, int, "num-states");
checkedarg(h->setNumSymbols, int, "num-symbols");
checkedarg(h->setMaxNumEpochs, int, "max-epochs");
checkedarg(h->setMinChange, float, "min-change");
o = h;
} else if ( "cHMM" == name ) {
vector<string> list = {HMM_TYPE};
HMM *h = new HMM(
/* hmmtype */ HMM_CONTINUOUS,
/* hmmodel */ find(list.begin(), list.end(), p.get<string>("hmmtype")) - list.begin(),
/* delta */ p.get<double>("delta"),
/* scaling */ false,
/* useNull */ false);
checkedarg(h->setCommitteeSize, int, "comitteesize");
checkedarg(h->setDownsampleFactor, int, "downsample");
o = h;
} else if ( "KNN" == name ) {
KNN *k = new KNN(
/* K */ p.get<int>("K-neighbors"),
/* useScaling */ false,
/* nullReject */ p.get<double>("null-coefficient") != 0,
/* coeff */ p.get<double>("null-coefficient"),
/* search */ p.get<int>("K-neighbors")==0,
/* minK */ p.get<int>("min-K"),
/* maxK */ p.get<int>("max-K"));
string distance = p.get<string>("distance");
if ( "euclidean" == distance ) k->setDistanceMethod(KNN::EUCLIDEAN_DISTANCE);
else if ( "cosine" == distance ) k->setDistanceMethod(KNN::COSINE_DISTANCE);
else if ( "manhattan" == distance ) k->setDistanceMethod(KNN::MANHATTAN_DISTANCE);
o = k;
} else if ( "DTW" == name ) {
vector<string> list = {DTW_REJECTION_MODE};
o = new DTW(
/* useScaling */ false,
/* useNullRejection */ p.get<double>("null-coefficient")!=0,
/* nullRejectionCoeff */ p.get<double>("null-coefficient"),
/* rejectionMode */ find(list.begin(), list.end(), p.get<string>("rejection-mode")) - list.begin(),
/* constrainWarpingPath */ p.get<double>("warping-radius")!=0,
/* radius */ p.get<double>("warping-radius"),
/* offsetUsingFirstSample */ false,
/* useSmoothing */ false,
/* smoothingFactor */ 0,
/* nullRjectionLikelihoodThreshold */ p.get<double>("null-threshold"));
} else if ( "FiniteStateMachine" == name ) {
o = new FiniteStateMachine(
p.get<int>("num-particles"),
p.get<int>("num-clusters"),
p.get<double>("transition-smoothing"),
p.get<double>("measurement-noise"));
} else if ( "ParticleClassifier" == name ) {
o = new ParticleClassifier(
p.get<int>("num-particles"),
p.get<double>("measurement-noise"),
p.get<double>("transition-sigma"),
p.get<double>("phase-sigma"),
p.get<double>("velocity-sigma"));
} else if ( "RandomForests" == name ) {
vector<string> list = {RF_TRAINING};
o = new RandomForests(
DecisionTreeClusterNode(),
p.get<int> ("forest-size"),
p.get<int> ("num-split"),
p.get<int> ("num-samples"),
p.get<int> ("max-depth"),
find(list.begin(), list.end(), p.get<string>("training-mode")) - list.begin(),
p.exist("remove-features"),
true);
} else if ( "SVM" == name ) {
vector<string> kernel_list = {SVM_KERNELS};
vector<string> type_list = {SVM_TYPES};
o = new SVM(
find(kernel_list.begin(), kernel_list.end(), p.get<string>("kernel")) - kernel_list.begin(),
find(type_list.begin(), type_list.end(), p.get<string>("type")) - type_list.begin(),
true,
true,
p.get<double>("gamma") == 0,
p.get<double>("gamma"),
p.get<int>("degree"),
p.get<double>("coef0"),
p.get<double>("nu"),
p.get<double>("C"),
false, 0);
} else if ( "ANBC" == name ) {
o = new ANBC(true,p.get<double>("null-coef")!=0,p.get<double>("null-coef"));
} else if ( "GMM" == name ) {
o = new GMM(p.get<int>("mixtures"),
true,
p.get<double>("null-coef")!=0,
p.get<double>("null-coef"),
p.get<int>("max-iterations"),
p.get<double>("epsilon"));
} else if ( "AdaBoost" == name ) {
vector<string> types = {ADABOOST_TYPES};
UINT type = find(types.begin(),types.end(),p.get<string>("prediction-type")) - types.begin();
if( "DS" == p.get<string>("weak-classifier") ) {
o = new AdaBoost(
DecisionStump(p.get<int>("num-steps")),
true,
p.get<double>("null-coef")!=0,
p.get<double>("null-coef"),
p.get<int>("max-iterations"),
type);
} else if ("RBF" == p.get<string>("weak-classifier") ) {
o = new AdaBoost(
RadialBasisFunction(
p.get<int>("num-steps"),
p.get<double>("pos-tresh"),
p.get<double>("min-alpha"),
p.get<double>("max-alpha")),
true,
p.get<double>("null-coef")!=0,
p.get<double>("null-coef"),
p.get<int>("max-iterations"),
type);
} else {
cerr << "unknown weak classifier in AdaBoost got: " << p.get<string>("weak-classifier") << endl;
exit(-1);
}
} else if ( "DecisionTree" == name ) {
vector<string> list = {DT_TRAINING};
o = new DecisionTree(DecisionTreeNode(),
p.get<int>("min-samples-per-node"),
p.get<int>("max-depth"),
p.exist("remove-features"),
find(list.begin(), list.end(), p.get<string>("training-mode")) - list.begin(),
p.get<int>("num-split"),
false);
} else if ( "MinDist" == name ) {
o = new MinDist(false,
p.get<double>("null-coef")!=0,
p.get<double>("null-coef"),
p.get<int>("num-clusters"));
} else if ( "Softmax" == name ) {
o = new Softmax(false,
p.get<double>("learning-rate"),
p.get<double>("min-change"),
p.get<double>("max-epochs"));
} else {
fstream fin; fin.open(name);
o = loadClassifierFromFile(fin);
fin.close();
}
if (o != NULL)
o->setNumInputDimensions(num_dimensions);
if (p.rest().size() > 0)
input_file = p.rest()[0];
return o;
}