-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Closed
Description
Hi, Neural Network gives me weird results. Maybe I miss something. Please help.
What is wrong?
Neural Network result is incorrect.
Where does it happen?
I'm running 2.0.0-alpha.12 on Node 13 and Mac.
How do we replicate the issue?
Firstly I tried:
const brain = require('brain.js');
const net = new brain.NeuralNetwork();
const trainingData = {
input: { a: 0, b: 1 },
output: { good: 1 },
};
net.train(trainingData);
const trainingData2 = {
input: { a: 1, b: 0 },
output: { bad: 1 },
};
net.train(trainingData2);
const result = net.run({ a: 0, b: 1 });
console.log(result);
// Output: { good: 0.060428500175476074 }
// I expect: { good: 1 }Then tried serialising as advised but still doesn't work:
const brain = require('brain.js');
// first training
const trainingData = {
input: { a: 0, b: 1 },
output: { good: 1 },
};
const net = new brain.NeuralNetwork();
net.train(trainingData);
const stringifiedNet = JSON.stringify(net.toJSON());
// second training
const trainingData2 = {
input: { a: 1, b: 0 },
output: { bad: 1 },
};
const net2 = new brain.NeuralNetwork();
net2.fromJSON(JSON.parse(stringifiedNet));
net2.train(trainingData2);
const stringifiedNet2 = JSON.stringify(net2.toJSON());
// prediction
const net3 = new brain.NeuralNetwork();
net3.fromJSON(JSON.parse(stringifiedNet2));
const result = net3.run({
a: 0,
b: 1,
});
console.log(result);
// Output: { good: 0.07364676147699356 }
// I expect: { bad: 0, good: 1 }
const result2 = net3.run({
a: 1,
b: 0,
});
console.log(result2);
// Output: { good: 0.07043380290269852 }
// I expect: { bad: 1, good: 0 }How important is this (1-5)?
4
Expected behavior (i.e. solution)
I expect NN to return other results (described in code comments).
Other Comments
You guys do an awesome job building brain.js!
EDIT: Seen this comment on StackOverflow: The keepNetworkIntact has been renamed to reinforce but can't see this property in INeuralNetworkTrainingOptions
EDIT2: I read somewhere I should pass all data every time I run train. Is there any way around it? I train the NN every day with new daily statistics. Seems insane to have to calculate them every time for all the previous days (i.e. past 2 years).
Metadata
Metadata
Assignees
Labels
No labels