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

ERROR - tf2onnx.tfonnx: Failed to convert node 'Mean'

Open heiyuxiaokai opened this issue 2 years ago • 2 comments

When I convert the delf model to onnx in tf2, python -m tf2onnx.convert --saved-model ./ --opset 11 --output model.onnx --verbose this error occurs: 2022-06-20 21:18:17,083 - VERBOSE - tf2onnx.tfonnx: Mapping TF node to ONNX node(s) 2022-06-20 21:18:17,157 - ERROR - tf2onnx.tfonnx: Failed to convert node 'Mean' (fct=<bound method ReduceOpBase.version_11 of <class 'tf2onnx.onnx_opset.reduction.ReduceOpBase'>>) OP=ReduceMean\nName=Mean\nInputs:\n\tPow:0=Pow, [1, -1, -1, 2048], 1\n\tmean_reduction_indices_0:0=Placeholder, [2], 6\nOutpus:\n\tMean:0=None, 1 Traceback (most recent call last): ValueError: get tensor value: 'mean_reduction_indices_0' must be Const

All opset versions have been tried.

heiyuxiaokai avatar Jun 20 '22 13:06 heiyuxiaokai

My Model: https://drive.google.com/file/d/1wnq9nCyOePdY7d4q3b3NJfcP4HIIREJ5/view?usp=sharing

heiyuxiaokai avatar Jun 21 '22 03:06 heiyuxiaokai

The error is raised from https://github.com/onnx/tensorflow-onnx/blob/76924dfd598858489009b93279b6f57e80fc841b/tf2onnx/onnx_opset/reduction.py#L31.

The second input of Mean op should be const axes instead of a Placeholder mean_reduction_indices_0. image

But it looks ok in frozen pb graph, image.

Need to make more investigation to check if it's something related to const folding.

hwangdeyu avatar Aug 11 '22 09:08 hwangdeyu