-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
A model with empty weights doesn't load #7865
Comments
Hi, @thekevinscott Thank you for bringing this issue to our attention and I tried to replicate the same issue from my end and I'm also getting the same error message which you've mentioned above. If I'm not wrong model with empty weights won't load in TFJs because TFJs uses the weights to initialize the model layers. If the weights are empty, the layers won't be initialized and the model won't be able to load or run Here is output from above code snippet for reference :
I tried to load |
Thanks for the feedback, @gaikwadrahul8 If I create the model and run a prediction through it, it works:
So it looks like a model can have empty weights if it’s created on the fly, but it can’t be loaded from a file. |
You're welcome and you understood correctly and I have edited my above comment where I loaded If you don't need further assistance on this issue, Could you please confirm if this issue is resolved for you ? Please feel free to close the issue if it is resolved ? Thank you! |
The point I was trying to make above is that creating a model on the fly with empty weights works and successfully runs on an input. Saving that model and reloading it fails. I would expect the behavior to be identical for both cases. Either both work, or both fail. Or is there a reason that loaded models exhibit different behavior? |
It appears the change was introduced in version Here is a code sandbox pinned to https://codesandbox.io/p/sandbox/admiring-snow-5hvhkl?file=%2Findex.js%3A1%2C1 The model loads and is able to run inference against a given tensor. |
Here is the change that introduced the behavior: 97cb1ff#diff-9279ae16c497b4a3d6660978362e8225dd135951408da17adddc65df2e9acff7R599 |
Hi, @thekevinscott Thank you for your analysis and pointing out the root cause for this issue with Thank you for noticing this issue with |
Sure thing I'll take a look |
Opened PR #7868 |
Hi, @thekevinscott Thank you for submitting the PR, Team will review your PR and will take appropriate action from their end. Thank you! |
Hi, @thekevinscott I see your this PR #7868 got merged to take care of this issue so could you please check from your end let us know, is it working as expected with If it's working as expected, please feel free to close this issue if it is resolved. Thank you! |
|
System information
npm
4.8.0
Describe the current behavior
A
model.json
with an empty array of weights fails to be loaded:Why would I want a model with empty weights?
I maintain a tool, UpscalerJS, for doing image upscaling in Javascript. It has a number of integration tests that require a functioning Tensorflow.js model, and it's helpful to keep that model as simple possible (a single upsampling layer) to assert behavior without significant test latency.
At some point tests were working, but a version upgrade somewhere along the line broke things. I haven't yet been able to isolate the version things changed.
Describe the expected behavior
I would expect a model with an empty weights array to load.
Standalone code to reproduce the issue
https://codesandbox.io/p/sandbox/jolly-firefly-2g63jk
Or, run the following code in Node:
The text was updated successfully, but these errors were encountered: