From ef39e92f2da854f8eddc03a59ef6269cfd1eba80 Mon Sep 17 00:00:00 2001 From: sbosse Date: Tue, 27 Aug 2024 00:16:05 +0200 Subject: [PATCH] Tue 27 Aug 00:14:56 CEST 2024 --- test/test-mlp3.js | 64 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 test/test-mlp3.js diff --git a/test/test-mlp3.js b/test/test-mlp3.js new file mode 100644 index 0000000..7001e9d --- /dev/null +++ b/test/test-mlp3.js @@ -0,0 +1,64 @@ +// MLP Function Approximation f(x)=y=x/2^3-5 + +var x = [ + 0, + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19 +]; + +x=ml.stats.utils.wrap(x); + +// y=Math.pow(x/2,3)-5 +var y = [ + -5, + -4.875, + -4, + -1.625, + 3, + 10.625, + 22, + 37.875, + 59, + 86.125, + 120, + 161.375, + 211, + 269.625, + 338, + 416.875, + 507, + 609.125, + 724, + 852.375 +]; + +var model = ml.learn({ + algorithm : ml.ML.MLP, + x : x, + y : y, + normalize:true, + regression: true, + epochs : 1000000, + hidden_layers : [3,4] +}); + +print(model) +print(merge(ml.stats.utils.wrap(ml.predict(model,x)),y,'c')); +