jam/test/test-mlp1.js

30 lines
566 B
JavaScript
Raw Normal View History

2024-08-27 00:16:09 +02:00
var x = [[1,1,1,0,0,0],
[1,0,1,0,0,0],
[1,1,1,0,0,0],
[0,0,1,1,1,0],
[0,0,1,1,0,0],
[0,0,1,1,1,0]];
var y = [[1, 0],
[1, 0],
[1, 0],
[0, 1],
[0, 1],
[0, 1]];
var model = ml.learner({
algorithm : ml.ML.MLP,
x : x,
y : y,
hidden_layers : [4,4,5]
});
var result = ml.train(model,{
epochs : 20000,
})
print (result)
print(toJSON(model).length+' Bytes')
a = [[1, 1, 0, 0, 0, 0],
[0, 0, 0, 1, 1, 0],
[1, 1, 1, 1, 1, 0]];
print(ml.classify(model,a));