0

I am working on converting an existing Pytorch model into a tf-lite model to see if it can speed up inference time and make it easier to deploy to mobile.

Planned steps:

  1. convert pytorch to onnx using torch.onnx.export().
  2. convert the onnx model to tensorflow using onnx-tf.
  3. use the tensorflow library to convert to a tf-lite model

Already completed:

Step 1 from above, which has been verified to perform correctly using the onnx runtime.

Blocking Issue:

When converting the Onnx representation to Tensorflow using onnx-tf, the following error message is shown:

ValueError: Depth of output (10) is not a multiple of the number of groups (32) for '{{node convolution_10}} = Conv2D[T=DT_FLOAT, data_format="NHWC", dilations=[1, 1, 1, 1], explicit_paddings=[], padding="VALID", strides=[1, 1, 1, 1], use_cudnn_on_gpu=true](transpose_70, split_14)' with input shapes: [?,?,?,320], [1,1,10,10].

I have also tried using onnx2keras to convert to a keras model but I'm met with a similar error message:

ValueError: Layer LAYER_13 weight shape (3, 3, 2, 1) is not compatible with provided weight shape (3, 3, 64, 1).

While it’s clear that the dimensions in the error messages are incompatible, it’s not clear why/how this mismatch is happening in this case, since the model works correctly both in pytorch and onnx.

Any ideas/suggestions?

Thanks

EDIT:

Link to stacktrace file and Python script:

https://drive.google.com/drive/folders/1U4CRxTk4Ds1mYcqIRPjqdMMp1uJif1hH?usp=sharing

user1884325
  • 2,530
  • 1
  • 30
  • 49

0 Answers0