Tue 27 Aug 00:14:56 CEST 2024
This commit is contained in:
parent
31d4a69df8
commit
ef39e92f2d
64
test/test-mlp3.js
Normal file
64
test/test-mlp3.js
Normal file
|
@ -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'));
|
||||
|
Loading…
Reference in New Issue
Block a user