tensorflow-onnx
tensorflow-onnx copied to clipboard
[keras2onnx][feature_columns]RuntimeError: Not support type: <class 'bytes'>
Describe the bug
Hi,there
that i use tf2onnx try convert keras model to onnx with dense_layers and lookuptable.
that I got error:
AttributeError Traceback (most recent call last)
File d:\workplace\34.env\python-3.10.4\lib\site-packages\tf2onnx\tf_utils.py:58, in tf_to_onnx_tensor(tensor, name)
56 try:
57 # Faster but fails on Unicode
---> 58 np_data = np_data.astype(np.str).astype(object)
59 except UnicodeDecodeError:
File d:\workplace\34.env\python-3.10.4\lib\site-packages\numpy\__init__.py:284, in __getattr__(attr)
282 return Tester
--> 284 raise AttributeError("module {!r} has no attribute "
285 "{!r}".format(__name__, attr))
AttributeError: module 'numpy' has no attribute 'str'
During handling of the above exception, another exception occurred:
RuntimeError Traceback (most recent call last)
Cell In[10], line 41
37 spec = (tf.TensorSpec((None, 1), dtype=tf.float32, name="conf"),
38 tf.TensorSpec((None, 1), tf.string, name="type"))
39 output_path = model.name + ".onnx"
---> 41 model_proto, _ = tf2onnx.convert.from_keras(model, input_signature=spec, extra_opset=[helper.make_opsetid("ai.onnx.contrib", 1)], opset=17,output_path=output_path)
File d:\workplace\34.env\python-3.10.4\lib\site-packages\tf2onnx\convert.py:494, in from_keras(model, input_signature, opset, custom_ops, custom_op_handlers, custom_rewriter, inputs_as_nchw, outputs_as_nchw, extra_opset, shape_override, target, large_model, output_path, optimizers)
...
62 except: # pylint: disable=bare-except
---> 63 raise RuntimeError("Not support type: {}".format(type(np_data.flat[0])))
64 return numpy_helper.from_array(np_data, name=name)
RuntimeError: Not support type: <class 'bytes'>
so i find #1500 .that we use same function,i run his code ,still get same error.
addition: convert code
model_proto, _ = tf2onnx.convert.from_keras(model, input_signature=spec, extra_opset=[helper.make_opsetid("ai.onnx.contrib", 1)], opset=17,output_path=output_path)
Urgency
System information
- OS Platform and Distribution (e.g., Linux Ubuntu 18.04*): windows
- TensorFlow Version: 2.11.0
- Python version: 3.10.4 (virtualenv)
- ONNX version (if applicable, e.g. 1.11*): 1.13.0
- ONNXRuntime version (if applicable, e.g. 1.11*):1.13.1
To Reproduce
Screenshots
Additional context
i mentioned issue #899,#920,#1995, that onnx don't support some operators https://github.com/onnx/tensorflow-onnx/issues/920#issuecomment-627756212 efficientnet-lite
Seems to have something to do with the numpy version.
For my It got fixed downgrading:
install tensorflow keras numpy==1.20 onnxruntime tf2onnx