brain.js: Value1.concat is not a function error
Hi Guys I Just started Exploring brain.js and facing some issue
const brain = require('brain.js');
const faker = require('faker');
const co = require('co');
let payload = [];
const generateData = function () {
return new Promise((resolve,reject) => {
const result = {input: {
color: faker.commerce.color(),
price: faker.commerce.price()
}, output: { [faker.commerce.product()] : 1 } }
return resolve(result);
})
}
for (let index = 0; index < 100; index++) {
payload.push(generateData());
}
Promise.all(payload).then(result => {
console.log(result);
var net = new brain.recurrent.LSTM();
net.train(result)
var output = net.run({ color: faker.commerce.color, price: faker.commerce.price });
console.log(output);
})
Above is My Code where i am trying to Generate Some Fake eCommerce Data of Product with price and color attribute and output as a name of product
But i am getting following Error
UnhandledPromiseRejectionWarning: TypeError: value1.concat is not a function
at DataFormatter.toIndexesInputOutput (F:\demo\brain.js-demo\node_modules\brain.js\dist\utilities\data-formatter.js:103:40)
at LSTM.formatDataIn (F:\demo\brain.js-demo\node_modules\brain.js\dist\recurrent\rnn.js:766:35)
at LSTM.setupData (F:\demo\brain.js-demo\node_modules\brain.js\dist\recurrent\rnn.js:750:26)
at LSTM.train (F:\demo\brain.js-demo\node_modules\brain.js\dist\recurrent\rnn.js:460:21)
at Promise.all.then.result (F:\demo\brain.js-demo\server.js:26:9)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
at Function.Module.runMain (module.js:695:11)
at startup (bootstrap_node.js:191:16)
at bootstrap_node.js:612:3
(node:12504) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch
block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:12504) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Can Anyone Help me out Understanding What am i Doing Wrong in my code ???
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 15 (9 by maintainers)
Thnx for Help
Here is a New Stackblitz i have created https://stackblitz.com/edit/brain-js-demo
Lemme know if found any solutions
@mubaidr I tried with net.run but still i am acing same issue
Here is My Sample Data that is getting generated from faker