forked from jaberg/DeepLearningBenchmarks
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathconvnet256.cc
66 lines (57 loc) · 2.1 KB
/
convnet256.cc
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
#include "libeblearn.h"
#include <time.h>
#include <sys/time.h>
using namespace std;
using namespace ebl; // all eblearn objects are under the ebl namespace
static double time_time() // a time function like time.time()
{
struct timeval tv;
gettimeofday(&tv, 0);
return (double) tv.tv_sec + (double) tv.tv_usec / 1000000.0;
}
typedef double t_net;
int main(int argc, char **argv) { // regular main without gui
init_drand(92394); // initialize random seed
intg n_examples = 20; // maximum training set size: 60000
idxdim dims(1,256,256); // get order and dimensions of sample
//! create 1-of-n targets with target 1.0 for shown class, -1.0 for the rest
idx<t_net> targets = create_target_matrix(10, 1.0);
idx<t_net> inputs(n_examples, 256, 256);
parameter<t_net> theparam(6000); // create trainable parameter
lenet5<t_net> l5(theparam, 256, 256, 7, 7, 5, 5, 7, 7, 4, 4, 120, 10);
// TODO: use an all-to-all connection table in second layer convolution
// Because that's what the other packages implement.
supervised_euclidean_machine<t_net, ubyte> thenet(
(module_1_1<t_net>&)l5,
targets,
dims);
supervised_trainer<t_net, ubyte,ubyte> thetrainer(thenet, theparam);
classifier_meter trainmeter, testmeter;
forget_param_linear fgp(1, 0.5);
thenet.forget(fgp);
// learning parameters
gd_param gdp(/* double leta*/ 0.0001,
/* double ln */ 0.0,
/* double l1 */ 0.0,
/* double l2 */ 0.0,
/* int dtime */ 0,
/* double iner */0.0,
/* double a_v */ 0.0,
/* double a_t */ 0.0,
/* double g_t*/ 0.0);
infer_param infp;
state_idx<t_net> dummy_input(1, 256, 256);
double t = time_time();
for (intg j = 0; j < n_examples; ++j)
{
thetrainer.learn_sample(dummy_input, j%10, gdp);
// TODO: iterate over mock dataset to simulate more realistic
// memaccess pattern
}
#ifdef USED_IPP
cout << "ConvLarge\teblearn{ipp}\t" << n_examples / (time_time() - t) << endl;
#else
cout << "ConvLarge\teblearn\t" << n_examples / (time_time() - t) << endl;
#endif
return 0;
}