tensorflow: Error while trying to serilize Image Captioning keras model '_UserObject' object is not callable'
System information
-
Have I written custom code (as opposed to using a stock example script provided in TensorFlow): example from https://www.tensorflow.org/tutorials/text/image_captioning
-
OS Platform and Distribution:Linux Ubuntu 18
-
TensorFlow installed from (source or binary): bin
-
TensorFlow version (use command below): v2.0.0-rc2-26-g64c3d38 2.0.0
-
Python version: 3.6.8
Describe the current behavior
tf.saved_model.save(encoder, “./models/1/encoder”)
model get serialized with errors
Describe the expected behavior encoder can be loaded without errors
Code to reproduce the issue
- train the model from https://www.tensorflow.org/tutorials/text/image_captioning example
tf.saved_model.save(encoder, "./models/1/encoder")
encoder = tf.saved_model.load("./models/1/encoder")
encoder(img_tensor_val)
raises the error > ‘_UserObject’ object is not callable
encoder.fc(img_tensor_val)
ValueError: Could not find matching function to call loaded from the SavedModel. Got:
Positional arguments (1 total):
* Tensor(“inputs:0”, shape=(1, 120, 64), dtype=float32)
Keyword arguments: {}
Expected these arguments to match one of the following 0 option(s):
Other info / logs W1227 00:41:32.831883 139767989909312 save_impl.py:77] Skipping full serialization of Keras model <main.CNN_Encoder object at 0x7f1daf5354e0>, because its inputs are not defined.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 42 (10 by maintainers)
NO! BOT STOP!
@veonua
Is this still an issue. Can you check with TF version 2.2 and see if the issue still persists?. Thanks!
This should be fixed in the latest version of tensorflow – can you update and check?
@veonua In the line
tf.saved_model.save(decoder, "/tmp/model",signatures=dncoder.call)In the
signatures=dncoder.call, passsignatures=decoder.callAlso if you have any more question as this question is purely a support question and not related to bug/performance, feature request, build/install or docs related issues, please post it in stack overflow.