30 lines
566 B
JavaScript
30 lines
566 B
JavaScript
|
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));
|