Skip to content

Example from the documentation: XOR constantly changes output readings upon restart #954

Open
@pihapi

Description

@pihapi
const brain = require('brain.js');
// provide optional config object, defaults shown.
const config = {
    inputSize: 20,
    inputRange: 20,
    hiddenLayers: [20, 20],
    outputSize: 20,
    learningRate: 0.01,
    decayRate: 0.999,
};
// create a simple recurrent neural network
const inet = new brain.recurrent.RNN(config);
inet.train([
    { input: [0, 0], output: [0] },
    { input: [0, 1], output: [1] },
    { input: [1, 0], output: [1] },
    { input: [1, 1], output: [0] },
], config);
console.log(inet.run([0, 0])); // [0]
console.log(inet.run([0, 1])); // [1]
console.log(inet.run([1, 0])); // [1]
console.log(inet.run([1, 1])); // [0]
  • output:
1
1
1
1

On Restart
output:

1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111

On Restart
output:

0
1
1
0

Version information

Nodejs: v18.12.1

Brain.js: any ( 2.0.0-beta.24, 1.6.1, 1.4.1 )

Other Comments

I have lost all trust in this library!
Maybe I am doing something wrong?

I am currently looking for a similar library to work with nodeJS

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions