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.

tf.io.loadWeights doesn't work with local file in nodejs

See original GitHub issue

To get help from the community, check out our Google group.

TensorFlow.js version

tfjs 0.11.7 tfjs-node 0.1.7

Browser version

node v8.7.0

Describe the problem or feature request

Got the following error when trying to load local weights file:

(node:73865) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): ReferenceError: fetch is not defined

Code to reproduce the bug / link to feature request

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

(async function(){
    let manifest = JSON.parse(fs.readFileSync('weights.json'));
    let weights = await tf.io.loadWeights(manifest, 'file://./weights');
})();

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
caisqcommented, Dec 30, 2018

This is now fixed in the latest release (0.2.1) of @tensorflow/tfjs-node and @tensorflow/tfjs-node-gpu

1reaction
ubertaocommented, Jul 5, 2018

@caisq The model was trained somewhere else, so far I only have access to the weights.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Save and load models | TensorFlow.js
Saving a model in node.js does not prevent it from being loaded in the browser. Below we will examine the different schemes available....
Read more >
Load Tensorflow js model from local file system in javascript
I know you're trying to load your model in a browser but if anybody lands here that's trying to do it in Node,...
Read more >
tensorflow/tfjs-converter v3.20.0 - npm.io
Convert a TF-Hub model file to TensorFlow.js graph model format. Use tf.loadGraphModel() to load the converted model in JavaScript. tf_saved_model ...
Read more >
tfjs-converter - GitHub Pages
js can access the local file system directly. Therefore, you can load the same frozen model from local file system into a Node.js...
Read more >
Tensorflow.js tf.loadLayersModel() Function - GeeksforGeeks
Tensorflow.js is a Google-developed open-source toolkit for ... and utilize them directly in the browser or with Node.js. ... A tf.io.
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