Open ghost opened 4 years ago
Maybe this helps narrow it down further: I also just tried loading the model in TF2.2rc4 using
restored_model = tf.keras.models.load_model("./test_export")
the error message is now:
tensorflow.python.saved_model.nested_structure_coder.NotEncodableError: No encoder for object [] of type [<class 'tensorflow.core.protobuf.struct_pb2.StructuredValue'>].
Do you have the same error with model.save('model',save_format='tf')
?
Yes
I can save/restore it using the hdf5 format, i.e. model.save(model, save_format="h5")
but I need it in the tensorflow format for tensorflow serving.
Is It a subclassed model?
Yes in my case it is, but the sample code above also fails using just the vanilla keras model class
It could be useful if you can open a small PR creating a test like this one that it can cover your case: https://github.com/tensorflow/addons/blob/master/tensorflow_addons/layers/tests/wrappers_test.py#L149
Lets the CI on the PR to fail you test case
Cool, done
Thanks
I'm also having this issue on tensorflow 2.3.
System information
Describe the bug
Building a model with a WeightNormalization layer and saving it as a tensorflow saved model throws this error under tensorflow 2.1:
ValueError: Attempted to save a function b'__inference_model_layer_call_and_return_conditional_losses_692' which references a symbolic Tensor Tensor("model/weight_normalization_1/compute_weights/mul:0", shape=(3, 3, 3, 128), dtype=float32) that is not a simple constant. This is not supported.
Saving works under tensorflow 2.2rc4, but subsequently trying to load the saved model then throws this error:
KeyError: '__inference_model_layer_call_and_return_conditional_losses_516'
Code to reproduce the issue