Skip to content
This repository has been archived by the owner on Oct 13, 2021. It is now read-only.

Unrecognized attribute: axes for operator Squeeze/RecduceSum #708

Open
chan4cc opened this issue Apr 14, 2021 · 2 comments
Open

Unrecognized attribute: axes for operator Squeeze/RecduceSum #708

chan4cc opened this issue Apr 14, 2021 · 2 comments

Comments

@chan4cc
Copy link

chan4cc commented Apr 14, 2021

System information

  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Ubuntu 16.04
  • ONNX Runtime installed from (source or binary): pip
  • ONNX Runtime version: 1.7.0
  • Python version: 3.6.8
  • Visual Studio version (if applicable):
  • GCC/Compiler version (if compiling from source):
  • CUDA/cuDNN version:
  • GPU model and memory:

To Reproduce

  • Describe steps/code to reproduce the behavior.
  1. convert h5 model created by tf.keras(tf1.12) to ONNX with code:
onnx_model = keras2onnx.convert_keras(model, model.name, target_opset=13, debug_mode=False)
  1. load onnx_model into sess:
 sess = onnxruntime.InferenceSession(onnx_model.SerializeToString())
  1. then step 2 report error like this:
Traceback (most recent call last):
  File "trans_model_format.py", line 85, in <module>
    keras_model_to_onnx(file_path)
  File "trans_model_format.py", line 49, in keras_model_to_onnx
    sess = onnxruntime.InferenceSession(onnx_model.SerializeToString())
  File "/home/zhanshen/.local/lib/python3.6/site-packages/onnxruntime/capi/onnxruntime_inference_collection.py", line 280, in __init__
    self._create_inference_session(providers, provider_options)
  File "/home/zhanshen/.local/lib/python3.6/site-packages/onnxruntime/capi/onnxruntime_inference_collection.py", line 309, in _create_inference_session
    sess = C.InferenceSession(session_options, self._model_bytes, False, self._read_config_from_model)
onnxruntime.capi.onnxruntime_pybind11_state.InvalidGraph: [ONNXRuntimeError] : 10 : INVALID_GRAPH : This is an invalid model. Error in Node:cos_sim/einsum/Shape:0_squeeze : Unrecognized attribute: axes for operator Squeeze

In my model build code with tf.keras, there is a tf.einsum op for calculating cosine sim.
And if I use tf.keras.layers.Dot layer to calculate cosine sim, the h5 model was also converted successfully and report cos_sim/dot/l2_normalize_1/Sum_reduce_min : Unrecognized attribute: axes for operator ReduceSum when loading onnx_model to sess

@chan4cc
Copy link
Author

chan4cc commented Apr 14, 2021

Before this, I opened microsoft/onnxruntime#7338.

@TruscaPetre
Copy link

This converter has worked for me. Although you have to train your model in tensorflow version 2.2, it might not work in other versions.
https://github.com/onnx/onnxmltools

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants