+ 6

Cannot Read Property LSTM

Using the recurrent constructor for brain.js, it keeps saying that it doesn't exist despite it working on the GitHub examples. It keeps throwing an error: "Cannot read property LSTM of undefined" How can I fix? https://code.sololearn.com/WJCc0q0DZ5y2/?ref=app

20th Aug 2019, 7:23 PM
Clueless Coder
Clueless Coder - avatar
26 odpowiedzi
+ 1
I believe that means that “brain.recurrent” is returning undefined, and as such you can’t access LSTM of undefined with the statement “brain.recurrent.LSTM”. The only conclusion I can draw from this is that “brain” has no “recurrent” property for whatever reason. Perhaps outdated brain.js? Maybe the example you found on github was outdated? I don’t know.
20th Aug 2019, 9:43 PM
Jason Stone
Jason Stone - avatar
+ 3
Jason Stone Thanks! cdnjs failed me once again so I got the official cdn instead. Although no text ends up showing. It's like the website half loads then gives up I was told it was going to be slow but I didn't expect the entire website to refuse to load. I've delt with slow codes with slow frame rates which are pretty much unplayable but nothing to this standard. It could be just on my end but I don't know
21st Aug 2019, 7:59 AM
Clueless Coder
Clueless Coder - avatar
+ 3
I'll try on my computer and see if it works there. Looks like the program is too big for the servers to handel
21st Aug 2019, 3:51 PM
Clueless Coder
Clueless Coder - avatar
+ 3
I don't know, the DOM won't load, only the styling. So I don't know why it won't work
21st Aug 2019, 3:56 PM
Clueless Coder
Clueless Coder - avatar
+ 3
I don't know 😂 I mean no text or content shows up, only the background colors and underlines. Not sure about JS
21st Aug 2019, 4:03 PM
Clueless Coder
Clueless Coder - avatar
+ 3
Jason Stone Sorry for not responding, Smash Bros tornament. Yes I agree, even the GitHub said they want to improve it in the future. Thanks for your help
21st Aug 2019, 4:21 PM
Clueless Coder
Clueless Coder - avatar
21st Aug 2019, 4:28 PM
Clueless Coder
Clueless Coder - avatar
+ 3
Jason Stone It works a lot better, thanks! I wonder if it's only me who's code loads for literally half a minute. Traversy Media said using brain.recurrent.LSTM a guy managed to make a neural network about Tweets. It predicts whether a Tweet was made by Donald Trump or Kim Kardashian. Waiting that long for each test must have taken the fun out of it
21st Aug 2019, 4:37 PM
Clueless Coder
Clueless Coder - avatar
+ 3
It's Sololearn. It's not really known for being the fastest. Like I said, I'll try tommorrow hopefully and check it out there. Phones are no where near as powerful as let's a top of the range, expensive, fast PC with Visual Studio 2019 working its magic. It's sad because if this was successful this would be the code I would be most proud of.
21st Aug 2019, 4:47 PM
Clueless Coder
Clueless Coder - avatar
+ 2
huh. Ok. Glad I could help!
21st Aug 2019, 3:40 PM
Jason Stone
Jason Stone - avatar
+ 2
too big for them to handle? but the web codes aren’t run on the servers. I found that with my horribly slow internet every code type except web takes a few seconds just to print “hello, world!” because of the time for signals to travel to and back from the server, but on web console.log prints things instantly.
21st Aug 2019, 3:54 PM
Jason Stone
Jason Stone - avatar
+ 2
How can the styling style anything if the DOM isn’t there to be styled? Do you mean the JS won’t run?
21st Aug 2019, 4:00 PM
Jason Stone
Jason Stone - avatar
+ 2
If the JS won’t run it could be an infinite loop. I also know that if there is an infinite loop simply going back to the JS or other tab then coming back to the output tab won’t reset it. You have to exit the code entirely and then come back to it. Also, if you’re using an external script make sure to give it time to download.
21st Aug 2019, 4:03 PM
Jason Stone
Jason Stone - avatar
+ 2
Hmm... background colors and underlines but not even any text. Very strange. In that case I’ll do some testing now.
21st Aug 2019, 4:05 PM
Jason Stone
Jason Stone - avatar
+ 2
I did a test. I put a couple words in the HTML and leaved the other tabs blank. Worked as expected, the words showed up fine. Then in the JS tab I put “while (true) {}” and then wen’t back to the output. It was blank. It seems the styles might load but not the text if the JS never terminates.
21st Aug 2019, 4:09 PM
Jason Stone
Jason Stone - avatar
+ 2
Ok, I gave your code a try and the output section stayed all white, totally blank for 20 seconds straight (there was an alert about painful slowness, so that worked fine)
21st Aug 2019, 4:11 PM
Jason Stone
Jason Stone - avatar
+ 2
Ok, I did some more testing and after like half a minute or more in the console it said “spam” so it indeed is VERY painfully slow
21st Aug 2019, 4:15 PM
Jason Stone
Jason Stone - avatar
+ 2
Changing “window.onload=“ to “var main=“ and then putting “window.onload=()=>{setTimeout(main,1000)}” somewhere gives time for the DOM to load before it runs the main program which takes like half a minute to train the net.
21st Aug 2019, 4:20 PM
Jason Stone
Jason Stone - avatar
+ 2
Your welcome. Glad I could help!
21st Aug 2019, 4:24 PM
Jason Stone
Jason Stone - avatar
+ 2
No. I meant: window.onload=()=>{setTimeout(main, 1000} var main=()=>{ //code } This was it gives the DOM 1000 milliseconds to load before calling the main part of the program
21st Aug 2019, 4:31 PM
Jason Stone
Jason Stone - avatar