BrainJS / BrainJS/brain.js

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

Open
#954 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
TypeScript
Stars
14.9k
Forks
1.1k
PR merge metrics
No merged PRs in 30d

Description

``` javascript
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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.