question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

var net = new brain.NeuralNetwork();

var trainingSet = [
  {
    input: [0.1, 0.1],
    output: [0.2]
  },
  {
    input: [0.2, 0.2],
    output: [0.4]
  },
  {
    input: [0.5, 0.1],
    output: [0.6]
  },
  {
    input: [0, 0.1],
    output: [0.1]
  },
  {
    input: [0.3, 0.1],
    output: [0.4]
  }
];

console.log(net.train(trainingSet, { // Object {error: 0.000099992701244754, iterations: 15197}
  errorThresh: 0.0001,
  learningRate: 0.3
}));

console.log(net.run([0.2, 0.4])); // [0.5480908025594973]
console.log(net.run([0.1, 0.4])); // [0.45124782633077687]
console.log(net.run([0.3, 0.4])); // [0.6239448854007088]
console.log(net.run([0.5, 0.4])); // [0.721436435561435]
console.log(net.run([0, 0.4])); // [0.3393225809755128]

I’ve tried a few different approaches and all sorts of input/outputs (and another library actually).

I really can’t get accurate data out. Any tips?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:10 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
wagenaartjecommented, Jun 18, 2017

@brandonros, you cannot expect a neural network to map a function with such a small dataset - you have included just 5 training samples. Note that a neural network will always minimize the error on the given dataset, so you cannot guarantee that a neural network will perform as good on a a dataset that it was not trained on.

There are infinite possibilities for addition. So at least, scale your dataset up to 100 samples - you can do this dynamically by generating them. Split these 100 samples up in óne group of 80, and one group of 20.

Train the network on the 80 samples until it has reachted a low error. Then, test your neural network on the 20 samples on which it wasn’t trained; if the error is low on those 20 samples, you know your neural network has successfully learned how to addition in some way or another.

0reactions
robertleeplummerjrcommented, Jun 19, 2017

The datset should be fine if you give it the loose principles of math, it just needs a good deal of them. Something I’ve tried that has worked nice is giving training results in every case from 0 to 10, for example. It depends what your ceiling is and your floor, but if it is a finite set you can give something general enough but specific to not get overfitting.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Accuracy Definition & Meaning - Merriam-Webster
The meaning of ACCURACY is freedom from mistake or error : correctness. How to use accuracy in a sentence.
Read more >
Accuracy and precision - Wikipedia
Accuracy and precision are two measures of observational error. Accuracy is how close a given set of measurements (observations or readings) are to...
Read more >
Accuracy Definition & Meaning - Dictionary.com
Accuracy definition, the condition or quality of being true, correct, or exact; freedom from error or defect; precision or exactness; correctness. See more....
Read more >
ACCURACY | definition in the Cambridge English Dictionary
the ability to do something without making mistakes: She says she can type 85 words per minute with 90% accuracy.
Read more >
Accuracy: Business Advisers - Financial Consultants
At Accuracy, our expert business advisers and financial consultants provide in-depth knowledge to corporate clients based on facts, figures and strategy.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found