【问题标题】:`Einsum is not implemented` error when convert onnx model to .pb model?将 onnx 模型转换为 .pb 模型时出现“未实现 Einsum”错误?
【发布时间】:2023-03-15 17:15:01
【问题描述】:

我正在尝试将 onnx 模型转换为 TensorFlow 的 .pb 模型。但是当我执行prepare 函数时,我得到了这个错误:NotImplementedError: Einsum is not implemented. 有什么建议可以解决这个问题吗?谢谢!

顺便说一下,这是我用来转换模型的代码:

import onnx
from onnx_tf.backend import prepare

def onnx2pb(model, pb_output_path, opset_version=12):
    tf_exp = prepare(onnx_model)  # prepare tf representation
    tf_exp.export_graph(pb_output_path)  # export the model

    
onnx_input_path = './model.onnx'
pb_output_path = './model.pb'
onnx_model = onnx.load(onnx_input_path)
onnx2pb(onnx_model, pb_output_path)

>>> below are the error report

  tf_exp = prepare(onnx_model)  # prepare tf representation
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/onnx_tf/backend.py", line 66, in prepare
    return cls.onnx_model_to_tensorflow_rep(model, strict)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/onnx_tf/backend.py", line 86, in onnx_model_to_tensorflow_rep
    return cls._onnx_graph_to_tensorflow_rep(model.graph, opset_import, strict)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/onnx_tf/backend.py", line 143, in _onnx_graph_to_tensorflow_rep
    output_ops = cls._onnx_node_to_tensorflow_op(onnx_node,
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/onnx_tf/backend.py", line 254, in _onnx_node_to_tensorflow_op
    exception.OP_UNIMPLEMENTED_EXCEPT(node.op_type)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/onnx_tf/common/exception.py", line 30, in __call__
    super(OpUnimplementedException, self).__call__(op, version, domain)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/onnx_tf/common/exception.py", line 12, in __call__
    raise self._func(self.get_message(*args, **kwargs))
NotImplementedError: Einsum is not implemented.
[Finished in 5.3s with exit code 1]

【问题讨论】:

    标签: tensorflow onnx


    【解决方案1】:

    我通过将torch.einsum 更改为相关矩阵乘法解决了这个问题:)

    【讨论】:

      猜你喜欢
      • 2020-03-31
      • 2020-05-23
      • 2018-06-14
      • 2020-11-23
      • 2018-10-05
      • 1970-01-01
      • 2020-02-12
      • 2022-10-13
      • 2023-01-31
      相关资源
      最近更新 更多