Tue 27 Aug 00:14:56 CEST 2024
This commit is contained in:
parent
e2601ac531
commit
7f4fdac4d9
34
test/test-cnn.js
Normal file
34
test/test-cnn.js
Normal file
|
@ -0,0 +1,34 @@
|
|||
var data = csv.read('test-cnn-DT.csv'),
|
||||
x,
|
||||
y;
|
||||
|
||||
data.shift();
|
||||
x=select(data,0,data[0].length-2);
|
||||
y=select(data,data[0].length-1);
|
||||
|
||||
|
||||
var model = ml.learn({
|
||||
algorithm:ml.ML.CNN,
|
||||
x:x, // [row1=[col1=[z1,z2,..],col2,..],row2,..]
|
||||
y:y,
|
||||
width:28,
|
||||
height:28,
|
||||
depth:1,
|
||||
normalize:[-.5,.5],
|
||||
iterations:100,
|
||||
layers:[
|
||||
// output Vol is of size 3x4x2 here
|
||||
{type:'input', out_sx:28, out_sy:28, out_depth:1},
|
||||
{type:'conv', sx:5, filters:8, stride:1, pad:2, activation:'relu'},
|
||||
{type:'pool', sx:2, stride:2},
|
||||
{type:'conv', sx:5, filters:16, stride:1, pad:2, activation:'relu'},
|
||||
{type:'pool', sx:3, stride:3},
|
||||
{type:'softmax', num_classes:10}
|
||||
],
|
||||
trainer : {method: 'adadelta',
|
||||
l2_decay: 0.001,
|
||||
batch_size: 10}
|
||||
});
|
||||
// print(model)
|
||||
for(var i=0;i<100;i++)
|
||||
print(y[i],ml.stats.utils.best(ml.classify(model,x[i]).w))
|
Loading…
Reference in New Issue
Block a user