Skip to content

trainInput function is acting strangely (and buggy) #532

@bdotsamir

Description

@bdotsamir

Here's your meme

image

What is wrong?

The function at https://github.com/BrainJS/brain.js/blob/master/src/recurrent/rnn.js#L211 behaves strangely.. the input is correct (an array of numbers) but it outputs NaN, which in turn causes the chain of functions to fail and my network doesn't train.
I investigated this further, and it turns out that the equation.predictTargetIndex(source, target) will go for a bit, then spit out NaN, causing the rest of the chain to be NaN.

Where does it happen?

Dude I don't even know. It happens when I try to train an LSTM network o.o

How do we replicate the issue?

  1. Run this code:
const messages = [ { input: 'string of words to check, essentially', output: 1 } ]

const brain = new brainjs.recurrent.LSTM({ hiddenLayers: [20, 20, 20] });
brain.train(messages, {
    iterations: 20000, 
    errorThresh: 0.001, 
    log: true, 
    logPeriod: 10,
    learningRate: 0.3, 
    momentum: 0.1,
    callback: null, 
    callbackPeriod: 10, 
    timeout: Infinity, 
  });

How important is this (1-5)?

4, mainly because this is the example provided in the README. It seems no matter what settings I adjust, the same issue arises.

Expected behavior (i.e. solution)

The network.. trains. No errors are thrown.

Other Comments

Here's what I got from adding a bunch of console.logs:
image

System info: KDE Neon 5.18, node 12.16.2, brain.js v2.0.0-alpha.12

Edit: 4/25/20 @ 18:21

This thing is so inconsistent it amazes me.

[
  {
     input: 'somebody once told me the world was gonna roll me',
     output: 0
  }
]

works, but

[
  {
    input: '<vulgar phrases here>',
    output: 1
  }
]

doesnt.

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