Brain.js: Question: LSTM with input / output gives unexpected output?

Created on 19 Jul 2020  路  2Comments  路  Source: BrainJS/brain.js


A GIF or MEME to give some spice of the internet

What is wrong?

This is mostly a question, this might be the expected outcome for this code.

When i train your LSTM "happy/sad" example and run it with some strings it has not seen before i get some unexpected outcomes.

console.log(net.run("I feel great about the world!"))
console.log(net.run("The world is a terrible place!"))
console.log(net.run("I am the greatest!"))
console.log(net.run("I am terrible"))
console.log(net.run("I am the sadest!"))
console.log(net.run("I am the happiest"))

yields

happy
sad
happy
the world!happy
happy
e!sad

Where does it happen?

Computer
MacBook Pro
Intel Core i7 2,6 GHz
16 GB

Env
node v10.20.1

How do we replicate the issue?

import brain from "brain.js"

const net = new brain.recurrent.LSTM()

net.train(
  [
    { input: "I feel great about the world!", output: "happy" },
    { input: "The world is a terrible place!", output: "sad" }
  ],
  { log: true, iterations: 10000 }
)

console.log(net.run("I feel great about the world!"))
console.log(net.run("The world is a terrible place!"))
console.log(net.run("I am the greatest!"))
console.log(net.run("I am terrible"))
console.log(net.run("I am the sadest!"))
console.log(net.run("I am the happiest"))

Expected behavior (i.e. solution)

instead of getting this result

happy
sad
happy
the world!happy
happy
e!sad

i would like to get this

happy
sad
happy
happy
happy
sad

Version information

Nodejs:

node v10.20.1

Browser:

N/A

Brain.js:

"brain.js": "^2.0.0-beta.1"

How important is this (1-5)?

5 if this is not expected

1 if i have misunderstood everything.

Other Comments

Really cool library i like it alot so far!

question

Most helpful comment

Issue-Label Bot is automatically applying the label question to this issue, with a confidence of 0.75. Please mark this comment with :thumbsup: or :thumbsdown: to give our bot feedback!

Links: app homepage, dashboard and code for this bot.

All 2 comments

Issue-Label Bot is automatically applying the label question to this issue, with a confidence of 0.75. Please mark this comment with :thumbsup: or :thumbsdown: to give our bot feedback!

Links: app homepage, dashboard and code for this bot.

Try adding more data.
Lack of data is one of the main reasons
NN's took so long to start being used.

Some structure to the the net it self is needed try:

const net = new brain.recurrent.LSTM({
inputSize: 1,
hiddenLayers: [5,5,5],
outputSize: 1
})
Play with the hiddenLayers see what comes up.

P.S the output is very expected and even wanted, this the net trying to deal
with something it never saw before.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lucaspojo picture lucaspojo  路  5Comments

robertleeplummerjr picture robertleeplummerjr  路  6Comments

iSumitBanik picture iSumitBanik  路  4Comments

ximik753 picture ximik753  路  3Comments

timendez picture timendez  路  3Comments