Save SavedModel fails for SetInputFeature
See original GitHub issueDescribe the bug
Error when attempting to call save_savedmodel
for a model that containers a set property. See error:
2020-10-19 03:06:47.001119: I tensorflow/compiler/xla/service/service.cc:176] StreamExecutor device (0): Host, Default Version
Traceback (most recent call last):
File "train.py", line 78, in <module>
train(args)
File "train.py", line 41, in train
ludwig_model.save_savedmodel(args.model_dir)
File "/usr/local/lib/python3.6/dist-packages/ludwig/api.py", line 1445, in save_savedmodel
self.model.save_savedmodel(save_path)
File "/usr/local/lib/python3.6/dist-packages/ludwig/models/ecd.py", line 82, in save_savedmodel
keras_model = self.get_connected_model(training=False)
File "/usr/local/lib/python3.6/dist-packages/ludwig/models/ecd.py", line 77, in get_connected_model
inputs = inputs or self.get_model_inputs(training)
File "/usr/local/lib/python3.6/dist-packages/ludwig/models/ecd.py", line 63, in get_model_inputs
self.input_features.items()
File "/usr/local/lib/python3.6/dist-packages/ludwig/models/ecd.py", line 62, in <dictcomp>
for input_feature_name, input_feature in
File "/usr/local/lib/python3.6/dist-packages/ludwig/features/base_feature.py", line 70, in create_input
return tf.keras.Input(shape=self.get_input_shape(),
File "/usr/local/lib/python3.6/dist-packages/ludwig/features/set_feature.py", line 127, in get_input_shape
return len(self.vocab),
AttributeError: 'SetInputFeature' object has no attribute 'vocab'
https://github.com/uber/ludwig/blob/master/ludwig/features/set_feature.py#L127
To Reproduce
Create a model definition with a set property - in my case I had two set properties for a regression output.
preprocessing:
text:
most_common_word: 10000
input_features:
# set features
- name: base_colour
type: set
- name: manufacturer_colour
type: set
# more features...
# regression output
output_features:
- name: days_online
type: numerical
Sample dataset for the three fields above:
days_online,base_colour,manufacturer_colour
14,white,white
8,meteor grey,
4,brown,
11,white,
44,white,fuji white
Expected behavior Expected to be able to create the tensorflow model.
Environment (please complete the following information):
- OS: Ubuntu
- Version: 18.04.3 LTS
- Python: 3.6.9
- Ludwig version: master (commit hash ab9bb7cac6287578e73b46579c18d518e2ddb5a6) ~0.3
- TF version: tensorflow:2.3.0-gpu
Additional context I was testing this so that I could produce the the TF pb file for visualizing the TF graph in tensorboard as I wasn’t able to do this with just the checkpoint and logs.
Issue Analytics
- State:
- Created 3 years ago
- Comments:5
Top Results From Across the Web
TensorFlow SavedModel export fails with AttributeError #34591
I'm following the tutorial exactly as it is here: https://www.tensorflow.org/tutorials/keras/text_classification_with_hub Finally, ...
Read more >Using the SavedModel format | TensorFlow Core
You can save and load a model in the SavedModel format using the following APIs: ... is saved, calling a tf.function with a...
Read more >TensorFlow Keras SavedModel throws a TypeError after being ...
The problem is that the TensorFlow SavedModel format does not actually serialize custom Python code. It only saves the TensorFlow graph ...
Read more >Export TensorFlow models in the SavedModel format
It stores supporting files for the prediction service. The variables directory stores the variables saved by calling the tf.train.Saver method.
Read more >Problem while loading a TensorForestEstimator saved using ...
I have trained a Random Forest Estimator using the Python API, and saved it in the SavedModel format. I am now trying to...
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
I confirm I was able to reproduce.
@tgaddair confirming this fix is working.