keras-onnx
keras-onnx copied to clipboard
Cannot convert saved model from tensorflow tutorial
Here is the gist
I'm following this tutorial Feature_columns. At the end of the notebook:
- Save the model
- Install keras2onnx
- Reload the model and convert
It failed with
tf executing eager_mode: True
tf.keras model eager_mode: False
WARNING:tensorflow:Layers in a Sequential model should only have a single input tensor, but we receive a <class 'dict'> input: {'PhotoAmt': <tf.Tensor 'features/PhotoAmt:0' shape=(None, 1) dtype=int64>, 'Vaccinated': <tf.Tensor 'features/Vaccinated:0' shape=(None, 1) dtype=string>, 'Type': <tf.Tensor 'features/Type:0' shape=(None, 1) dtype=string>, 'Sterilized': <tf.Tensor 'features/Sterilized:0' shape=(None, 1) dtype=string>, 'Gender': <tf.Tensor 'features/Gender:0' shape=(None, 1) dtype=string>, 'Breed1': <tf.Tensor 'features/Breed1:0' shape=(None, 1) dtype=string>, 'Health': <tf.Tensor 'features/Health:0' shape=(None, 1) dtype=string>, 'Fee': <tf.Tensor 'features/Fee:0' shape=(None, 1) dtype=int64>, 'FurLength': <tf.Tensor 'features/FurLength:0' shape=(None, 1) dtype=string>, 'Color1': <tf.Tensor 'features/Color1:0' shape=(None, 1) dtype=string>, 'Color2': <tf.Tensor 'features/Color2:0' shape=(None, 1) dtype=string>, 'Age': <tf.Tensor 'features/Age:0' shape=(None, 1) dtype=int64>, 'MaturitySize': <tf.Tensor 'features/MaturitySize:0' shape=(None, 1) dtype=string>}
Consider rewriting this model with the Functional API.
WARNING:tensorflow:Issue encountered when serializing table_initializer.
Type is unsupported, or the types of the items don't match field type in CollectionDef. Note this is a warning and probably safe to ignore.
'NoneType' object has no attribute 'name'
---------------------------------------------------------------------------
InvalidArgumentError Traceback (most recent call last)
<ipython-input-34-276b6a4511f1> in <module>()
----> 1 onnx_model = keras2onnx.convert_keras(reload_model)
7 frames
/usr/local/lib/python3.6/dist-packages/six.py in raise_from(value, from_value)
InvalidArgumentError: Cannot convert a Tensor of dtype resource to a NumPy array.
Python Version: 3.6.9
Tensorflow Version: 2.3.0 (I can also reproduce with 2.3.1)
keras2onnx version: Successfully installed fire-0.3.1 keras2onnx-1.7.0 onnx-1.7.0 onnxconverter-common-1.7.0
Thank you
Solve it? How to solve it?