python tfjs.converter.load_keras_model fails if Variable names already used
See original GitHub issueTo get help from the community, check out our Google group.
TensorFlow.js version
tensorflowjs version 0.4.0 keras version 2.1.4
Browser version
None ( this is a python issue)
Describe the problem or feature request
If you create a model, save it to it to tfjs.json format and try to load it within the same python session, it will fail because of a weight renaming issue.
Code to reproduce the bug / link to feature request
import os
import tensorflowjs as tfjs
import keras
OUTPUT_DIR = "/tmp/tfjs-output-dir"
dense_a = keras.layers.Dense(2, input_dim = 3)
model = keras.models.Sequential([dense_a])
tfjs.converters.save_keras_model(model os.path.join(OUTPUT_DIR, "seq_a_tfjs"))
model_prime = tfjs.converters.load_keras_model(os.path.join(
OUTPUT_DIR, "seq_a_tfjs", "model.json"))
outputs
Using TensorFlow backend.
Traceback (most recent call last):
File "tiny_nested_model_a_min.py", line 26, in <module>
model_prime = tfjs.converters.load_keras_model(os.path.join(OUTPUT_DIR, "seq_a_tfjs", "model.json"))
File "/usr/local/google/home/bileschi/env/a/local/lib/python2.7/site-packages/tensorflowjs/converters/keras_tfjs_loader.py", line 208, in load_keras_model
use_unique_name_scope=use_unique_name_scope)
File "/usr/local/google/home/bileschi/env/a/local/lib/python2.7/site-packages/tensorflowjs/converters/keras_tfjs_loader.py", line 74, in _deserialize_keras_model
weights_list.append(weights_dict[weight_name])
KeyError: u'dense_1_1/kernel'
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:8 (2 by maintainers)
Top Results From Across the Web
Uncaught (in promise) Error: Provided weight data has no ...
Unfortunately, when I try to load the JSON model I get this error: Uncaught (in promise) Error: Provided weight data has no target...
Read more >Can't load keras model exported with tfjs.converters
Hi Timothee,. It's freezing up for me too - then I get an error about weights names. When you write the model, can...
Read more >How to Convert a Keras SavedModel into a Browser-based ...
If you're a Python developer who works with Keras SavedModels, this article is for you. Perhaps you're not sure how to use SavedModels...
Read more >@tensorflow/tfjs-converter - npm
A python pip package to convert a TensorFlow SavedModel or TensorFlow Hub module to a web friendly format. If you already have a...
Read more >Unclear error from tensorflowjs_converter of USE large from ...
When I run tensorflowjs_converter --input_format=tf_hub ... I correctly followed the directions in tensorflow/tfjs/tree/master/tfjs-converter on Github.
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
If you load the model three times you get three versions o the same model, no weight sharing. It modifies the eight names with the number plus underscore method.
On Sat, Jun 2, 2018 at 1:49 PM Daniel Smilkov notifications@github.com wrote:
– Stan Bileschi Ph.D. | SWE | bileschi@google.com | 617-230-8081
Reassigning to @davidsoergel for follow-up investigation.