Repository navigation
Expand file tree
/
Copy pathconfig.hpp
More file actions
109 lines (89 loc) · 2.35 KB
/
Copy pathconfig.hpp
File metadata and controls
109 lines (89 loc) · 2.35 KB
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
#include "defs.hpp"
#include <cstdio>
#pragma once
#define CONFIG_ARG_MAX_BYTES 128
/* Available activation functions */
enum activation { TANH, RELU, SMRELU };
/* Available network types */
enum networkType { DENSE, CONVOLUTIONAL };
/* Available batch types */
enum batchtype { DETERMINISTIC, STOCHASTIC };
/* Available hessian approximation types */
enum hessiantype { BFGS_SERIAL, LBFGS, IDENTITY };
/* Available stepsize selection methods */
enum stepsizetype { FIXED, BACKTRACKINGLS, ONEOVERK };
class Config {
private:
/* Linked list for reading config options */
struct config_option {
struct config_option *prev;
// config_option_t prev;
char key[CONFIG_ARG_MAX_BYTES];
char value[CONFIG_ARG_MAX_BYTES];
};
/* Helper function: Parse the config file */
config_option *parsefile(char *path);
public: /* List all configuration options here */
/* Data set */
const char *datafolder;
const char *ftrain_ex;
const char *ftrain_labels;
const char *fval_ex;
const char *fval_labels;
const char *weightsopenfile;
const char *weightsclassificationfile;
int ntraining;
int nvalidation;
int nfeatures;
int nclasses;
/* Neural Network */
int nchannels;
int nlayers;
MyReal T;
int activation;
int network_type;
int openlayer_type;
MyReal weights_open_init;
MyReal weights_init;
MyReal weights_class_init;
/* XBraid */
int braid_cfactor0;
int braid_cfactor;
int braid_maxlevels;
int braid_mincoarse;
int braid_maxiter;
MyReal braid_abstol;
MyReal braid_abstoladj;
int braid_printlevel;
int braid_accesslevel;
int braid_setskip;
int braid_fmg;
int braid_nrelax;
int braid_nrelax0;
/* Optimization */
int batch_type;
int nbatch;
MyReal gamma_tik;
MyReal gamma_ddt;
MyReal gamma_class;
int stepsize_type;
MyReal stepsize_init;
int maxoptimiter;
MyReal gtol;
int ls_maxiter;
MyReal ls_factor;
int hessianapprox_type;
int lbfgs_stages;
int validationlevel;
/* Constructor sets default values */
Config();
/* Destructor */
~Config();
/* Reads the config options from file */
int readFromFile(char *configfilename);
/* Writes config options to the file (File must be open!) */
int writeToFile(FILE *outfile);
/* Returns a stepsize, depending on the selected stepsize type and current
* optimization iteration */
MyReal getStepsize(int optimiter);
};