Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

501
Views
when loading a model in tensorflow.js for node, the weights aren't loaded/saved

When I load a trained model (In tensorflow.js within Node.js) that I have previously saved, the model topology is being loaded, but none of the weights are loaded (so I have to train the model from scratch). No errors are thrown.

To save the model, I am using:

async function save(path) {
    //misc. unrelated code goes here
    await model.save('file://' + path);
}

All files appear (model.json and weights.bin), and no errors are thrown.

To load the file, I am using :

async function load(path) {
    //misc. unrelated code goes here.
    model = await tf.loadLayersModel('file://' + path + '/model.json');
}

Again, no errors are thrown. The model topology is loaded correctly. The weights aren't though, and the model behaves as if I had just constructed/compiled it.

I am using tfjs-node save:

const tf = require('@tensorflow/tfjs');
require("tfjs-node-save");

I would really appreciate any help or advice!!! Thank you!

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

save() and loadLayersModel() are async functions.

model.save(url).then(result => console.log(result));

tf.loadLayersModel(url).then(result => console.log(result))

about 4 years ago · Juan Pablo Isaza Report

0

So it turns out this was just a dumb mistake.

I had a wrapper function to add some functionality to model.compile().

For some godforsaken reason, in that function, I called my initialization function, which overwrote the model.

tl;dr, don't overwrite a model you want to keep.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!