Brain.js: LSTM broken output

Created on 17 Mar 2020  路  7Comments  路  Source: BrainJS/brain.js

What is wrong?

Running a value against the network gives some strange outputs

Where does it happen?

In brain.recurrent.LSTM on my Surface, latest version of Windows, x64

How do we replicate the issue?

  1. Run this code in brain.js:
const brain = require('brain.js');
const net = new brain.recurrent.LSTM();

const trainingData = [
  {
    input: 'Hello',
    output: 'Hi'
  },
  {
    input: 'Hi',
    output: 'Hello'
  },
  {
    input: 'Greetings!',
    output: 'Hello'
  },
  {
    input: 'Hello',
    output: 'Greetings!'
  },
  {
    input: 'Hi, How is it going?',
    output: 'Good'
  },
  {
    input: 'Hi, How is it going?',
    output: 'Fine'
  },
  {
    input: 'Hi, How is it going?',
    output: 'Okay'
  },
  {
    input: 'Hi, How is it going?',
    output: 'Great'
  },
  {
    input: 'Hi, How is it going?',
    output: 'Could be better.'
  },
  {
    input: 'Hi, How is it going?',
    output: 'Not so great.'
  }
];

net.train(trainingData, {
  log: true,
  logPeriod: 100,
  learningRate: 0.3,
  iterations: 2000
});

const output = net.run('hi');
console.log(output);

How important is this (1-5)?

5

Expected behavior (i.e. solution)

I should have gotten this response (or something simillar):
"Hello"

Other Comments

Instead of "Hello", I got NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN

bug discussion

Most helpful comment

馃憤 Looking into this now, fyi.

All 7 comments

Are you actually able to train with this format?

[
  {
    "question": "Hello",
    "answer": "Hi"
  },...

Are you actually able to train with this format?

[
  {
    "question": "Hello",
    "answer": "Hi"
  },...

Sorry, I added my question wrongly. I just updated it to include the most accurate information possible.

馃憤 Looking into this now, fyi.

The only fix I found for it is to create a set of key-value pairs like this:

{
  input: 'Hi, How is it going?',
  output: '0'
}

Where 0 corresponds to "Great" after getting the output of the network.

Any update on this? Thanks

I have create a working demo here: https://runkit.com/mubaidr/brain-lstm

Training does complete and network returns output too. You need to provide better training set though. Also for more information on this topic, please check:
https://github.com/BrainJS/brain.js/issues/535
https://github.com/BrainJS/brain.js/issues/235
https://github.com/BrainJS/brain.js/issues/217

@robertleeplummerjr please

I think the only way to fix this is to not use this method of creating chatbots. There are plenty of other ways to create deep learning chatbots like Tensorflow.js with the Seq2seq model. Will close this issue now.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

VEXLife picture VEXLife  路  4Comments

shyamaprasadpatra picture shyamaprasadpatra  路  4Comments

AkashGutha picture AkashGutha  路  5Comments

dan-ryan picture dan-ryan  路  4Comments

lucaspojo picture lucaspojo  路  5Comments