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.

Neural network output values over 1?

See original GitHub issue

What is wrong?

after training on iris data https://archive.ics.uci.edu/ml/datasets/Iris/ output of one iris is massively higher than the others

How do we replicate the issue?

download the csv of data

const brain = require('brain.js');
const net = new brain.NeuralNetwork();
const fs = require('fs');

const data = fs.readFileSync('./iris.csv').toString();
const trainingData = data.split('\r\n').map((d) => {
    const [slength, swidth, plength, pwidth, flower] = d.split(',');
    return {
        input: {
            slength: slength / 10,
            swidth: swidth / 10,
            plength: plength / 10,
            pwidth: pwidth / 10,
        },
        output: {
            [flower]: 1,
        },
    };
});
const trainResults = net.train(trainingData);
console.log(trainResults);
const result = net.run({ 
    slength: 0.51,
    swidth: 0.35,
    plength: 0.13999999999999999,
    pwidth: 0.1 });

console.log(result);

How important is this (1-5)?

3

Expected behavior

{ 'Iris-setosa': 0.9973204731941223,
  'Iris-versicolor': 0.003389077726751566,
  'Iris-virginica': 2.462011443240403e-13 }

should be more like

{ 'Iris-setosa': 0.9973204731941223,
  'Iris-versicolor': 0.003389077726751566,
  'Iris-virginica': 0.003 }

Other Comments

training results

{ error: 0.008838672393814171, iterations: 20000 }

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
robertleeplummerjrcommented, Jan 6, 2019

The other option you can go with is formatting the output as a string, such as using .toFixed(14).

Example:

2.462011443240403e-13.toFixed(14); // -> "0.00000000000025"
1reaction
robertleeplummerjrcommented, Jan 6, 2019

It’s exponent values. An effort to make it more computationally easy and/or visually friendly. 13 zeros vs 2 zeros. Happens to the best of us.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Is it possible to get an output value greater than 1 (for ... - Quora
If you want the output greater than 1, you can set the activation function to give 0 till some threshold and after that...
Read more >
Can Neural Networks Output Numbers > 1? - Stack Overflow
You can let the 0 and 1 represent binary positions of a numeric value. Say you have 10 output neurons, then you can...
Read more >
Can I have a neural network output values >100?
The reason these networks output numbers between 0 and 1 is in the layer activations of the network.
Read more >
Configuring a Neural Network Output Layer | Enthought, Inc.
This shows how a multi-label problem can identify more than one label for a given sample: by classifying instances that have a value...
Read more >
Everything you need to know about Neural Networks and ...
Because of this properties it allows the nodes to take any values between 0 and 1. In the end, in case of multiple...
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