load/convert onnx model into pytorch

445 Views Asked by At

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)
<ipython-input-64-b734fd4e372a> in <module>
      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))
0

There are 0 best solutions below