onnx2torch icon indicating copy to clipboard operation
onnx2torch copied to clipboard

(Loop OP) need to GNN model based on keras to ONNX which can be converted into pytorch

Open senysenyseny16 opened this issue 1 year ago • 0 comments

Discussed in https://github.com/ENOT-AutoDL/onnx2torch/discussions/138

Originally posted by Alicodee February 15, 2023 I need to use GNNExplainer which requires pytorch model. However, my GNN model is written in keras libraries. I tried to use this library to load my onnx model and convert into pytorch. Can Anyone help me to resolve this errors? Here are the errors i got from it.

import tf2onnx

from keras2onnx import convert_keras

Load the Keras model

keras_model = model

Convert the Keras model to ONNX format

onnx_model, _ = tf2onnx.convert.from_keras(model)

Save the ONNX model to a file

with open('./my_onnx_model.onnx', 'wb') as f: f.write(onnx_model.SerializeToString())

import onnx

onnx_model = onnx.load('./my_onnx_model.onnx')

import onnx from onnx2torch import convert

torch_model_1 = convert(onnx_model)


NotImplementedError Traceback (most recent call last) in 2 from onnx2torch import convert 3 ----> 4 torch_model_1 = convert(onnx_model) 5 6 # from onnx2pytorch import ConvertModel

/working/Ali_code/custom_model_env/GNN/lib/python3.6/site-packages/onnx2torch/converter.py in convert(onnx_model_or_path, save_input_names, attach_onnx_mapping) 105 domain=onnx_node.domain, 106 operation_type=onnx_node.operation_type, --> 107 version=version, 108 ) 109

/working/Ali_code/custom_model_env/GNN/lib/python3.6/site-packages/onnx2torch/node_converters/registry.py in get_converter(operation_type, version, domain) 67 converter = _CONVERTER_REGISTRY.get(description, None) 68 if converter is None: ---> 69 raise NotImplementedError(f'Converter is not implemented ({description})') 70 71 return converter

NotImplementedError: Converter is not implemented (OperationDescription(domain='', operation_type='Loop', version=13))

senysenyseny16 avatar Mar 15 '23 05:03 senysenyseny16