question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

fromJSON not Working (I think I solved it)

See original GitHub issue

Me in a Nutshell

DISCLAIMER: I think I solved it, explanation below. If I just swapped a problem by another, please inform me.

What is wrong?

When I am trying to load a trained NN from a file, I get an error saying that I cannot read property ‘bias’ of undefined.

Where does it happen?

In the fromJSON function

How do we replicate the issue?

I replicated it by just trying to load a trained model from memory.

How important is this (1-5)?

It prevented me from using trained models, which is a big deal, so I guess it’s, like, 4 or 5. I may be stupid tho, maybe I messed up saving and reading the JSON somehow.

Expected behavior (i.e. solution)

It should’ve loaded the model.

Here’s how I fixed it (there is probably a nicer way, but I didn’t want to get into how the library works and stuff) : I figured by debugging that the loop for(var j in nodes) goes for some reason to the 398th property of the object (the layer has only 397, and I figured that’s one too much). All I did then was swapping the for ... in ... format to a standard loop: for (var t = 0; t < nodes.length; t++) and then just assigning var j = t.toString() since t was the number as a string.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
robertleeplummerjrcommented, Feb 24, 2019

Are you going to open a PR for this issue? We’d love to gain you as a contributor!

1reaction
ArsalanMaqsoodcommented, Mar 25, 2019

const lstm = new brain.recurrent.LSTM(); lstm.fromJSON(myjson); const result = lstm.train(trainingData, { iterations: 15000, log: details => console.log(details), errorThresh: 0.011 });

const updatedjson = lstm.toJSON();

//, { flag: ‘a+’ } fs.writeFile(“results.json”, JSON.stringify(updatedjson), function (err) { if (err) throw err; console.log(‘The “data to write” was appended to file!’); });

result.json file needs to have train data for new training and old training

how can i do this?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can't Resolve fromJson - Stack Overflow
the first parameter gson is not valid. one of the overloads -which i think you are trying to use- takes a String that...
Read more >
[solved] QJsonDocument not loading fromJson - Qt Forum
I have tried using the file. readAll() in fromJson and it still does not work.. What does data.
Read more >
Solved: Renderer fromJson - Esri Community
I tried it but it did not work. As I understand it, the fromJSON method is build exactly for what I try to...
Read more >
An Introduction to JQ - Earthly.dev
Other actions, I know how they work, but I have to think about them every time. ... So I solve my problem but...
Read more >
Solved: Extract string values from JSON Parse
Solved : I cannot for the life of me get flow to extract each value ... So using your suggestion i think this...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found