keras-onnx icon indicating copy to clipboard operation
keras-onnx copied to clipboard

keras2onnx.convert_keras failed with TypeError

Open forbywang opened this issue 5 years ago • 1 comments

i trained model with TF2.0 and saved as .pb files use tf.keras.models.load_model with custom_objects but keras2onnx.convert_keras failed

File ".\model_test.py", line 41, in model = covert_onnx(model) File ".\model_test.py", line 30, in covert_onnx onnx_model = keras2onnx.convert_keras(model, model.name) File "C:\ProgramData\Miniconda3\lib\site-packages\keras2onnx\main.py", line 83, in convert_keras return convert_topology(topology, name, doc_string, target_opset, channel_first_inputs) File "C:\ProgramData\Miniconda3\lib\site-packages\keras2onnx\topology.py", line 322, in convert_topology cvt(scope, operator, container) File "C:\ProgramData\Miniconda3\lib\site-packages\keras2onnx_builtin.py", line 270, in convert_tf_space_to_batch pads=reshaped_transposed_pad_x) File "C:\ProgramData\Miniconda3\lib\site-packages\keras2onnx\common\onnx_ops.py", line 84, in apply_op apply_func(self._scope, ox_inputs, outputs, self._container, operator_name=name, **attrs) File "C:\ProgramData\Miniconda3\lib\site-packages\onnxconverter_common\onnx_ops.py", line 662, in apply_pad container.add_initializer(pads_name, onnx_proto.TensorProto.INT64, [len(pads)], pads) File "C:\ProgramData\Miniconda3\lib\site-packages\keras2onnx\common\interim.py", line 75, in add_initializer tensor = helper.make_tensor(name, onnx_type, shape, content) File "C:\ProgramData\Miniconda3\lib\site-packages\onnx\helper.py", line 173, in make_tensor getattr(tensor, field).extend(vals) File "C:\ProgramData\Miniconda3\lib\site-packages\google\protobuf\internal\containers.py", line 282, in extend new_values = [self._type_checker.CheckValue(elem) for elem in elem_seq_iter] File "C:\ProgramData\Miniconda3\lib\site-packages\google\protobuf\internal\containers.py", line 282, in new_values = [self._type_checker.CheckValue(elem) for elem in elem_seq_iter] File "C:\ProgramData\Miniconda3\lib\site-packages\google\protobuf\internal\type_checkers.py", line 171, in CheckValue raise TypeError(message) TypeError: 'deeplabv3plus/expanded_conv_16_depthwise/StatefulPartitionedCall/StatefulPartitionedCall/depthwise/SpaceToBatchND_reshape_00' has type <class 'str'>, but expected one of: (<class 'int'>,)

forbywang avatar Jul 23 '20 04:07 forbywang

Which keras2onnx version is it? Can you try keras2onnx master? If still not working, can you provide an example for us to debug?

jiafatom avatar Jul 23 '20 15:07 jiafatom