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

Attribute new_axis_mask not supported

Open rtm-1dyakonov opened this issue 3 years ago • 5 comments

I am trying to convert model created from TensorFlow Object Detection API from saved_model.pb to Onnx format.

Unfortunately, next issue arrises: ValueError: StridedSlice: attribute new_axis_mask not supported

Here you can find my model either in saved_model and checkpoint formats.

rtm-1dyakonov avatar Dec 29 '21 15:12 rtm-1dyakonov

Could you also provide a simple repro script python code? This issue is related to this line tensor.py#L785 StridedSlice.

hwangdeyu avatar Dec 31 '21 05:12 hwangdeyu

We were encountering the same issue when we tried to convert a model for which we wrote a custom layer. We were at first a bit confused because we nowhere explicitly used a StridedSlice but figured it was somewhere in the implementation of one of the functions we used.

What fixed the issue for us, oddly enough, was to explicitly specify the newest opset. i.e.:

    model = tf.keras.models.load_model(model_path)
    tf2onnx.convert.from_keras(model, output_path="model.onnx")

threw the same error @rtm-1dyakonov encountered above, but

    model = tf.keras.models.load_model(model_path)
    tf2onnx.convert.from_keras(model, output_path="model.onnx", opset=15)

did not. I guess there may be something wrong with the default opset? Hope that helps :)

paulfauthmayer avatar Jan 14 '22 08:01 paulfauthmayer

Starting from opset 10, tf2onnx changed the way to handle StridedSlice op and accepted "new_axis_mask" attribute. So your solution is expected.

fatcat-z avatar Mar 19 '22 08:03 fatcat-z

Just newly installed tf2onnx and ran into this issue using default values. Should the default opset be set higher to avoid these problems? I'd say ML is a fast enough moving field currently that newer features should be preferred to compatibility for now.

Regenhardt avatar May 28 '22 22:05 Regenhardt

Just newly installed tf2onnx and ran into this issue using default values. Should the default opset be set higher to avoid these problems? I'd say ML is a fast enough moving field currently that newer features should be preferred to compatibility for now.

Yes, there is another PR changing the default opset to 13. Please look forward to next release. Thanks!

fatcat-z avatar May 29 '22 02:05 fatcat-z