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.

Blank output when input string.length > ~100 LSTM/GRU

See original GitHub issue

A GIF or MEME to give some spice of the internet

What is wrong?

I can get the toy examples working like the happy, sad example on the documentation. But when I increase the length of the sentence, I start getting blank strings as output “”. Through experimentation it seems to have to do with sentence length and happens at around 100 characters.

Where does it happen?

running node 10.7 on pc and mac

How do we replicate the issue?

run this code as is to see working example. Then swap out the commented variable happySentence and see that the outputs become blank string

The callback outputs will start to get the right answer really quickly; around 150 iterations. But nothing ever gets output in the longer sentence, even when approaching tens of thousands of iterations

const net = new brain.recurrent.GRU();
        const happySentence = "is upset that he can't update his Facebook by texting it... and might cry as a result School"
        // const happySentence = 'is upset that he can\'t update his Facebook by texting it... and might cry as a result School Today'
        console.log(happySentence.length)
        const sadSentence = 'im meeting up with one of my besties tonight! Cant wait!! - GIRL TALK!!'
        net.train([
                {input: happySentence, output: [1]},
                {input: sadSentence, output: [0]},
            ],
            {
                iterations: 20000,    // the maximum times to iterate the training data --> number greater than 0
                errorThresh: 0.005,   // the acceptable error percentage from training data --> number between 0 and 1
                log: true,           // true to use console.log, when a function is supplied it is used --> Either true or a function
                logPeriod: 25,        // iterations between logging out --> number greater than 0
                learningRate: .1,    // scales with delta to effect training rate --> number between 0 and 1
                momentum: .1,        // scales with next layer's change value --> number between 0 and 1
                callback: function(){
                    console.log(net.run(happySentence))
                },       // a periodic call back that can be triggered while training --> null or function
                callbackPeriod: 25,   // the number of iterations through the training data between callback calls --> number greater than 0
                timeout: Infinity     // the max number of milliseconds to train for --> number greater than 0
            });

        const output = net.run(happySentence);
        expect(output).equal(1)

How important is this (1-5)?

5 because it doesn’t work

Expected behavior (i.e. solution)

the output of either versions of happySentence should have been 1

Other Comments

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:10 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
robertleeplummerjrcommented, Oct 8, 2018

Working: https://jsfiddle.net/robertleeplummerjr/xw68qesp/6/

We probably should document this before this issue closes.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How can I read an input string of unknown length?
Enter while securing an area dynamically. E.G. #include <stdio.h> #include <stdlib.h> char *inputString(FILE* fp, size_t size){ //The size ...
Read more >
Text Generation With LSTM Recurrent Neural Networks in ...
In this tutorial, you will split the book text up into subsequences with a fixed length of 100 characters, an arbitrary length.
Read more >
C program to find the length of a string - GeeksforGeeks
The task is to find the length of the string. Examples: Input: str = "Geeks" Output: Length of Str is : 5 Input:...
Read more >
Counting No. of Parameters in Deep Learning Models by Hand
from keras.layers import Input, Dense, SimpleRNN, LSTM, GRU, Conv2D ... Example 1.1: Input size 3, hidden layer size 5, output size 2.
Read more >
Java String length() Method With Examples
Answer: In the below program, we have changed the length of the String by replacing the substring with a blank. We have taken...
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