forked from BIDData/BIDMach
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmnistlr.ssc
executable file
·48 lines (39 loc) · 1.11 KB
/
mnistlr.ssc
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
class xopts extends Learner.Options with SFilesDS.Opts with GLM.Opts with ADAGrad.Opts;
val ncats = 10;
def learnMNIST = {
val opts = new xopts;
implicit val ec = threadPool(4);
val ds = new SFilesDS(opts);
val nn = new Learner(
ds,
new GLM(opts),
null,
new ADAGrad(opts),
opts);
(nn, ds, opts)
};
val (nn, ds, opts) = learnMNIST;
val dir = "/data/MNIST8M/parts";
opts.fnames = List(FilesDS.simpleEnum(dir+"/cats%02d.smat.lz4", 1, 0),
FilesDS.simpleEnum(dir+"/part%02d.smat.lz4", 1, 0));
opts.nstart = 0;
opts.nend = 70;
opts.order = 0;
opts.lookahead = 2;
opts.featType = 1;
opts.fcounts = icol(10,784);
opts.eltsPerSample = 300;
opts.links = 2*iones(10,1);
opts.targets = mkdiag(ones(10,1)) \ zeros(10, 784);
opts.rmask = zeros(1,10) \ ones(1, 784);
opts.autoReset = false
opts.batchSize = 500;
opts.npasses = 1;
opts.lrate = 0.001; // for logistic
nn.train
opts.nstart = 71;
opts.nend = 80;
opts.npasses=1;
opts.links = 2*iones(10,1);
nn.model.asInstanceOf[GLM].mylinks <-- opts.links
nn.repredict