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

NHWC tensor format Tensorflow

Open sonfire186 opened this issue 5 years ago • 16 comments

The Conv2D op currently only supports the NHWC tensor format on the CPU. The op was given the format: NCHW

How to make a convert?

sonfire186 avatar Dec 19 '19 06:12 sonfire186

I also confused in this question, do you have solved ?

sicong-li avatar Dec 24 '19 11:12 sicong-li

No

sonfire186 avatar Dec 24 '19 12:12 sonfire186

Because you are running on CPU. Have 3 way for you: 1.Install tensorflow build with mkl, it support ncwh, 2. modify your code to change input datatype from ncwh to nhwc, 3. Run your model on GPU

uname0x96 avatar Dec 24 '19 12:12 uname0x96

  1. Not suitable
  2. Yes, this is correct, but I did not find a guide on how to do it
  3. It does not work

sonfire186 avatar Dec 24 '19 13:12 sonfire186

1.Easy way:https://pypi.org/project/intel-tensorflow/ 2. That is your problem with your code. Try to find where you feed data and what node you pass data with the wrong format. 3.You mean your problem still meets? or you can't run your model on GPU?

uname0x96 avatar Dec 24 '19 16:12 uname0x96

  1. This installer does not suit me. I have TF serving model
  2. Yes

sonfire186 avatar Dec 24 '19 16:12 sonfire186

I assume the NHWC problem has been fixed by using tensorflow 2.x and the corresponding (most recent) version of onnx and onnx-tf. However in the most recent version other problems occur, at least when trying to convert from pytorch -> onnx -> tf frozen graph -> tflite (which is probably what most people want). See #614 and #617

mgarbade avatar May 13 '20 07:05 mgarbade

unfortunately I do not use tf2.X because of bugs.

sonfire186 avatar May 13 '20 07:05 sonfire186

True, I was recently examining the tensorflow frozen graph (using tf 2.2 ) build from onnx and it still complains about the NHWC problem.

mgarbade avatar Jun 09 '20 18:06 mgarbade

setting os.environ["CUDA_VISIBLE_DEVICES"]="-1" (as mentioned in this reply https://github.com/onnx/onnx-tensorflow/issues/614#issuecomment-625251872) fixes the issue for me.

diff. versions of library I'm using:

torch==1.6.0
torchvision==0.7.0
onnx==1.7.0
onnxmltools==1.7.0
tensorflow==2.3.0
tensorflow-addons==0.11.0
onnxruntime==1.4.0
git+https://github.com/onnx/onnx-tensorflow.git (currently, it's onnx-tf==1.6.0)

pushpendrapratap avatar Aug 30 '20 02:08 pushpendrapratap

i meet the same poblem, have u fixed it?

shaqing avatar Feb 04 '21 07:02 shaqing

@shahirdaya not fixed

sonfire186 avatar Feb 05 '21 17:02 sonfire186

@sonfire86 I did not work on this so not sure. Thanks

shahirdaya avatar Feb 16 '21 15:02 shahirdaya

I remembered that the onnx2keras library had an option to switch the dimensions and rearrange the expected input to NHWC (as opposed to Pytorch's NCHW). Isn't it supported on this library?

talcs avatar Oct 21 '21 10:10 talcs

1.Easy way:https://pypi.org/project/intel-tensorflow/ 2. That is your problem with your code. Try to find where you feed data and what node you pass data with the wrong format. 3.You mean your problem still meets? or you can't run your model on GPU?

The first way fixes my same problem. Thanks.

turned2670 avatar Aug 25 '23 06:08 turned2670

The first way fixes my same problem. Thanks.

turned2670 I can't make it work. Would you please explain how exactly did you solve the problem?

robbinc91 avatar Aug 30 '23 06:08 robbinc91