Set the weight file location of tf.loadLayersModel
See original GitHub issueTensorFlow.js version
1.3.2
Describe the problem or feature request
Hello. As I tried to create and use a simple model, it seems that the location of the weight file can be set automatically or only the prefix of the path can be set. In the case of me, I want to set the position of the weight like setting the position of the model, but I wonder if there is a reason not to set it.
The API I am expecting is as follows.
const loadModel = await tf.loadLayersModel(model.default,{weightPath:weight.default});
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
Save and load models | TensorFlow.js
Weights : These are binary files that store the weights of a given model in an efficient format. They are generally stored in...
Read more >Tensorflow.js tf.loadLayersModel() Function - GeeksforGeeks
Weight files are assumed to be co-located with the model.json file by default. Return Value: Promise<tf.LayersModel>. Example 1: Javascript ...
Read more >TFJS Layers Model Not Loading Weights Correctly
It seems to fetch the weight files in a different order each time it is executed. Does anyone know if this is expected...
Read more >when loading a model in tensorflow.js for node, the weights ...
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 =...
Read more >@tensorflow/tfjs-converter - npm
Use tf.loadLayersModel() to load the model in JavaScript. ... weight manifest file); group1-shard\*of\* (collection of binary weight files).
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
Tensorflow.js version: 2.0.1
I’m having an issue during this process.
I’m using Firebase Storage, which has a url looking like this:
This is close to a standard directory-like convention (
/
=>%2F
) but doesn’t conform exactly. When I load the model, the parsed shard URL is:<APP_URL>/o/group1-shard1of1.bin?<Query Params>
which cuts off the directory structure and yields a
404
. The queries on their own, and themodel.json
query in the program, yield200
status code responses and the correct results.I’ve tried loading the model in two ways.
Method 1:
An example from the docs specifies the entire path, so I when do that by adjusting the function to:
I still get the same result of:
Method 2:
I’ve adjusted the
model.json
file’sweightsManifest
from:to
(and the JS code to)
And it was surprisingly unsuccessful (same incorrect
404
weights URL). My assumption was this directed the second query, and my only explanation is that this value is being overridden in some way. Although this is the less ideal method, I was fairly certain it would work.I am experiencing the same issue as described by @Rcuz8 above. Manually replacing “Functional” by “Model” in the model.json file solved the issue for me.