keras-onnx
keras-onnx copied to clipboard
TypeError: value "" is not valid attribute data type.
I'm trying to convert a tensorflow.python.keras.engine.functional.Functional keras model to onnx. The model was saved using the model.save() method in tf.keras, saving the model in the SavedModel format.
When trying to convert the model, I'm getting the error below:
>>> import tensorflow as tf
>>> model = tf.keras.models.load_model("my_model")
>>> import keras2onnx
>>> output_model_path="my_model.onnx"
>>> onnx_model = keras2onnx.convert_keras(model, model.name)
tf executing eager_mode: True
tf.keras model eager_mode: False
WARN: No corresponding ONNX op matches the tf.op node keras_learning_phase of type PlaceholderWithDefault
The generated ONNX model needs run with the custom op supports.
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/tblstri/anaconda3/envs/TENSORFLOW_CPU/lib/python3.6/site-packages/keras2onnx/main.py", line 83, in convert_keras
return convert_topology(topology, name, doc_string, target_opset, channel_first_inputs)
File "/home/blstri/anaconda3/envs/TENSORFLOW_CPU/lib/python3.6/site-packages/keras2onnx/topology.py", line 322, in convert_topology
cvt(scope, operator, container)
File "/home/tblstri/anaconda3/envs/TENSORFLOW_CPU/lib/python3.6/site-packages/keras2onnx/_tf_ops.py", line 80, in pass_thru_converter
**attrs)
File "/home/tblstri/anaconda3/envs/TENSORFLOW_CPU/lib/python3.6/site-packages/onnxconverter_common/oopb.py", line 141, in add_node
name=self._scope.get_unique_operator_name(name), **attrs)
File "/home/blstri/anaconda3/envs/TENSORFLOW_CPU/lib/python3.6/site-packages/keras2onnx/common/interim.py", line 133, in add_node
node = helper.make_node(op_type, inputs, outputs, **attrs)
File "/home/tblstri/anaconda3/envs/TENSORFLOW_CPU/lib/python3.6/site-packages/onnx/helper.py", line 110, in make_node
for key, value in sorted(kwargs.items()))
File "/home/tblstri/anaconda3/envs/TENSORFLOW_CPU/lib/python3.6/site-packages/onnx/helper.py", line 110, in <genexpr>
for key, value in sorted(kwargs.items()))
File "/home/tblstri/anaconda3/envs/TENSORFLOW_CPU/lib/python3.6/site-packages/onnx/helper.py", line 394, in make_attribute
'value "{}" is not valid attribute data type.'.format(value))
TypeError: value "" is not valid attribute data type.
tf version = 2.3.1
keras2onnx version = 1.7.0
onnx version = 1.8.0
Try keras.backend.set_learning_phase(0)?
That gets rid of the warning, but doesn't get rid of the error.
I got a similiar problem. But the model was created by keras_bert and saved as .h5 format.
Try tensorflow 2.2.0?