我正在使用大脑JS使用“循环LSTM”来预测一些数据。我使用nodeJS作为接口,并使用express对其进行训练并预测输出。
以下是一些基本训练数据:
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' },
]);
培训部分:
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');
}
});
输出:
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');
}
});
现在,当我在字符串中的任意位置使用以下任意字母进行训练或预测时,就会出现此问题。
j k m n q v x z
确切错误字符串:
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
如果有人可以对此问题发表一点看法,将非常有帮助。