forked from BIDData/BIDMach
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestdnn.ssc
executable file
·46 lines (33 loc) · 1.04 KB
/
testdnn.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
:silent
val dir="c:/code/BIDMach/data/rcv1/"
val a0 = loadSMat(dir + "docs.smat.lz4")(0->100000,?)
val c0 = loadFMat(dir + "cats.fmat.lz4")(0->100,?)
val rr = rand(c0.ncols,1);
val (ss, ii) = sort2(rr);
val a = a0(?,ii);
val c = c0(?,ii);
val ta = loadSMat(dir + "testdocs.smat.lz4")(0->100000,?)
val tc = loadFMat(dir + "testcats.fmat.lz4")(0->100,?)
val pc = zeros(tc.nrows, tc.ncols)
val (nn,opts)=DNN.learnerX(a,c)
opts.aopts = opts
opts.batchSize=2000
opts.reg1weight = 0.0001
opts.npasses = 5
opts.addConstFeat=false;
opts.links = iones(100,1);
opts.lrate = 0.4f // best for 6-layer
opts.lrate = 0.2f
opts.texp = 0.4f
opts.nweight = 1e-4f
DNN.dlayers4(7,500,0.5f,100,opts,2)
nn.train
val dnn = nn.model.asInstanceOf[DNN]
val (mm,mopts) = DNN.predictor(dnn, ta, pc);
mopts.batchSize=1000
mopts.predict=true;
mm.predict
val rc = roc2(pc, tc, 1-tc, 1000)
val counts = sum(tc,2);
:silent
println("auc6 = %5.4f, auc weighted mean = %5.4f" format (mean(rc)(6), (mean(rc) * counts / sum(counts)).dv));