Failed to load Sequential model created containing a Model layer
See original GitHub issueTo get help from the community, check out our Google group.
TensorFlow.js version
0.4.0 (This is the Python library) 0.11.1 (For JavaScript library)
Browser version
I’m using the Python library, but also tried on Google Chrome Version 66.0.3359.139
Describe the problem or feature request
I have a Keras model trained using transfer learning on top of ResNet50. Initially, I trained a separate model using bottleneck features from ResNet50. Later, I attempted to combine these two models. The model summary is as below:
In [8]: model.summary()
_________________________________________________________________
Layer (type) Output Shape Param #
=================================================================
resnet50 (Model) (None, None, None, 2048) 23587712
_________________________________________________________________
reshape_2 (Reshape) (None, 1, 1, 2048) 0
_________________________________________________________________
sequential_4 (Sequential) (None, 133) 272517
=================================================================
Total params: 23,860,229
Trainable params: 23,807,109
Non-trainable params: 53,120
_________________________________________________________________
I was successful in using this combined model to perform predictions without generating bottleneck features – despite a warning saying I have an uncompiled model.
I then attempted to use tensorflowjs to save this keras model, and read it again. This is the error I received:
In [9]: tfjs.converters.save_keras_model(model, './letstry3')
In [10]: tfjs.converters.load_keras_model('./letstry3/model.json')
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
<ipython-input-10-08bba8228c6f> in <module>()
----> 1 tfjs.converters.load_keras_model('./letstry3/model.json')
~/udacity/udacity-dev/lib/python3.6/site-packages/tensorflowjs/converters/keras_tfjs_loader.py in load_keras_model(config_json_path, weights_path_prefix, weights_data_buffers, load_weights, use_unique_name_scope)
206 return _deserialize_keras_model(config_json['modelTopology'],
207 weight_entries=weight_entries,
--> 208 use_unique_name_scope=use_unique_name_scope)
~/udacity/udacity-dev/lib/python3.6/site-packages/tensorflowjs/converters/keras_tfjs_loader.py in _deserialize_keras_model(model_topology_json, weight_entries, use_unique_name_scope)
72 weights_list = []
73 for weight_name in weight_names:
---> 74 weights_list.append(weights_dict[weight_name])
75 model.set_weights(weights_list)
76
KeyError: 'conv1_2/kernel'
I also attempted to load this model via your JavaScript library, and I got this error:
Uncaught (in promise) Error: Could not find weights in manifest with names: conv1/kernel, conv1/bias, bn_conv1/gamma, ..(truncated)
I am pretty new to Keras and Tensorflow so it is entirely possible I am doing something completely out of the intended use case. In the event that is true, I would really love some advice on what to do instead.
Thanks!
Code to reproduce the bug / link to feature request
Please see above.
Issue Analytics
- State:
- Created 5 years ago
- Comments:12
Top GitHub Comments
FYI: as a temporary work around, the command line seems to work here:
Still investigating on the code side.
Alright, I’m able to reproduce the error locally. Looking to find the root cause.