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.

trainInput function is acting strangely (and buggy)

See original GitHub issue

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.

Issue Analytics

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

github_iconTop GitHub Comments

2reactions
robertleeplummerjrcommented, May 6, 2020

The problem is that you are using a number, and should be using a string: output: 1 should be output: '1'

However, I’m adding a fix that will automatically convert this for you.

0reactions
robertleeplummerjrcommented, May 6, 2020

Also, your net is three LSTM layers, which seems pretty deep. Two would likely be plenty, from my naive perspective.

Read more comments on GitHub >

github_iconTop Results From Across the Web

A synthetic distributed genetic multi-bit counter - ScienceDirect
A design for genetically encoded counters is proposed via repressor-based circuits. An N-bit counter reads sequences of input pulses and ...
Read more >
STATIC DEPENDENCE ANALYSIS IN AN ...
Now that parallel architectures are common, software must exploit multiple cores to fully utilize hardware resources and achieve efficient ...
Read more >
Newest 'neural-network' Questions - Page 57 - Stack Overflow
I want to apply a scipy stats function as a layer in a Keras neural network, something like this: from scipy import stats...
Read more >
Frequency-Domain Modelling of Reset Control Systems using ...
Through Describing Function (DF) analysis [15] it is shown that the CI inflicts 52◦ less phase lag than the in gain similar linear...
Read more >
Electric Railway Handbook - Heritage Trolley
The most str~king single feature of this develop ment is the light weight car; this has been accompanied by more scientific design of...
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