From 7f4fdac4d91554993ab1c5c732485ebcb8d98491 Mon Sep 17 00:00:00 2001 From: sbosse Date: Tue, 27 Aug 2024 00:15:03 +0200 Subject: [PATCH] Tue 27 Aug 00:14:56 CEST 2024 --- test/test-cnn.js | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 test/test-cnn.js diff --git a/test/test-cnn.js b/test/test-cnn.js new file mode 100644 index 0000000..9f5c7d6 --- /dev/null +++ b/test/test-cnn.js @@ -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))