Brain.js: Unrecognized Character issue in brain JS training and output

Created on 15 Jul 2018  路  4Comments  路  Source: BrainJS/brain.js

I'm using brain JS for predicting some data using 'recurrent LSTM'. I'm using nodeJS,express as the interface to train it and predict output.

Here is some basic training data :

var 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' },
]);

Training Part :

app.get('/learn', function(req, res) {
    var params = req.query;
    if( params.str !== '' )
    {
        net.train([
            { input: params.str, output: params.output }
        ]);
        res.send('Training Done');
    }
    else{
        res.send('Nothing to train');
    }
});

Output :

app.get('/predict', function(req, res) {
    var params = req.query;
    if( params.str !== '' )
    {
        var output = net.run(params.str);  // 'happy'
        res.send(output);
    }
    else{
        res.send('Nothing to predict');
    }
});

Now the issue appears when I'm using any of the following letters anywhere in the string for training or for prediction.
j k m n q v x z
Exact error String :

Error: unrecognized character "q"
    at DataFormatter.toIndexes (/var/www/html/brainjs/node_modules/brain.js/dist/utilities/data-formatter.js:85:17)
    at DataFormatter.toIndexesInputOutput (/var/www/html/brainjs/node_modules/brain.js/dist/utilities/data-formatter.js:101:23)
    at LSTM.formatDataIn (/var/www/html/brainjs/node_modules/brain.js/dist/recurrent/rnn.js:766:35)
    at LSTM.run (/var/www/html/brainjs/node_modules/brain.js/dist/recurrent/rnn.js:378:24)
    at /var/www/html/brainjs/index.js:56:23
    at Layer.handle [as handle_request] (/var/www/html/brainjs/node_modules/express/lib/router/layer.js:95:5)
    at next (/var/www/html/brainjs/node_modules/express/lib/router/route.js:137:13)
    at Route.dispatch (/var/www/html/brainjs/node_modules/express/lib/router/route.js:112:3)
    at Layer.handle [as handle_request] (/var/www/html/brainjs/node_modules/express/lib/router/layer.js:95:5)
    at /var/www/html/brainjs/node_modules/express/lib/router/index.js:281:22
bug

Most helpful comment

This is known issue, a fix is in progress. More info: https://github.com/BrainJS/brain.js/issues/217

All 4 comments

This is known issue, a fix is in progress. More info: https://github.com/BrainJS/brain.js/issues/217

Try again and let us know if our fix didn't resolve it. Ty again for helping us help you.

Thanks a lot @mubaidr @robertleeplummerjr .

I tested, the issue has been resolved.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

omer54463 picture omer54463  路  6Comments

timendez picture timendez  路  3Comments

tyt34 picture tyt34  路  5Comments

shopsoy picture shopsoy  路  3Comments

AkashGutha picture AkashGutha  路  5Comments