Can't manage to have a string get analysed by brain.js
See original GitHub issueWhat is wrong?
The training network doesn’t train, it returns NaN for the data that it should have analysed.
Where does it happen?
In the app.js run through node, after receiving data from the Twitter API
How do we replicate the issue?
- Use the dummy data below
const trainingData =[
{
input:'RT @ObamaFoundation: This week—50 years since Dr. Martin Luther King, Jr. was killed—@BarackObama and @RepJohnLewis sat down with a group o…',
output:{
Barack:1
}
},
{
input:'Incredible to have a Chicago team in the Final Four. I’ll take that over an intact bracket any day! Congratulations to everybody @LoyolaChicago - let’s keep it going!',
output:{
Barack:1
}
},
{
input:'In Singapore with young people who are advocating for education, empowering young women, and getting involved all over Southeast Asia with a profoundly optimistic commitment to building the world they want to see. ',
output:{
Barack:1
}
},
{
input:'Very thankful for President Xi of China’s kind words on tarrifs and automobile barriers...also, his enlightenment on intellectual property and technology transfers. We will make great progress together!',
output:{
Donald:1
}
},
{
input:'Last night, it was my great honor to host America’s senior defense and military leaders for dinner at the White House. America’s military is the GREATEST fighting force in the history of the world. They all have my pledge of unwavering commitment to our men and women in uniform! ',
output:{
Donald:1
}
},
{
input:'A TOTAL WITCH HUNT!!!',
output:{
Donald:1
}
}
]
- Convert the input using encode
function encode(arg) {
return arg.split('').map(x => (x.charCodeAt(0) / 400));
}
- Run it through net.trainAsync()
How important is this (1-5)?
A 4, since I think this should be able to work, but it could be my bad too!
Expected behavior (i.e. solution)
The data should have been analysed, but somewhere inbetween something went wrong!
Other Comments
I’m think the encoding method might not be correct here.
Issue Analytics
- State:
- Created 5 years ago
- Comments:17 (11 by maintainers)
Top Results From Across the Web
Brain js NaN when predicting is a combination of words is ...
Apparently, brain.js only understands numeric data. But it can be trained to represent each character as a neuron in the net.
Read more >Build and train a neural network with nothing but ...
In this tutorial, we will explore one of them -- Brain.js -- and show how it's possible to build, train, and use a...
Read more >Useful string methods - Learn web development | MDN
Now that we've looked at the very basics of strings, let's move up a gear and start thinking about what useful operations we...
Read more >brain.js
brain.js is a GPU accelerated library for Neural Networks written in JavaScript. This is a continuation of the harthur/brain, ...
Read more >Find if a string is interleaved of two other strings | DP-33
The simple solution doesn't work if the strings A and B have some common characters. For example, let the given string be A...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The api is the same in whatever javascript you are on. I started experimenting with a lstm version, which I believe is the answer here, I’ll see what I can come up with as well.
Here is a better working prototype (the other one I forgot to click save on) https://jsfiddle.net/8Lvynxz5/38/