pytorch2keras icon indicating copy to clipboard operation
pytorch2keras copied to clipboard

Keras model exception when predict "Default MaxpoolingOp only supports NHWC on device type CPU"

Open YangMingJerry opened this issue 5 years ago • 3 comments
trafficstars

Describe the bug I successfully convert my CNN pytorch model to a keras model, and want to predict an input for testing it, but this exception occurs. My CPU is intel 8700 and my tensorflow and keras are both up to date. To Reproduce Snippet of your code

Expected behavior A clear and concise description of what you expected to happen.

Logs If applicable, add error message to help explain your problem.

Environment (please complete the following information):

  • OS: [e.g. iOS]
  • Python [e.g. Python 2, Python 3]
  • Version [e.g. v0.1.11]

Additional context Add any other context about the problem here.

YangMingJerry avatar Nov 05 '20 07:11 YangMingJerry

On the homepage readme.md read the information under Important Notice here.

Alternatively you can pass change_ordering=True to the function pytorch_to_keras. And transpose your inputs to be in the format used by Tensorflow/Keras.

rand_tens = np.random.rand(1, 3, 224, 224)
print(rand_tens.shape)
(1,3,224,224)

transposed = np.transpose(rand_tens, [0, 2, 3, 1])
print(transposed.shape)
(1, 224, 224, 3)

henriwoodcock-old avatar Jan 04 '21 17:01 henriwoodcock-old

When passing change_order=True to the function it sais NotImplementedError: change_ordering for Slice is not implemented. So please, try to fix this. I really need it :(

AzazelHD avatar Jan 06 '21 13:01 AzazelHD

@AzazelHD I think that's an Onnx2Keras issue.

henriwoodcock-old avatar Jan 06 '21 17:01 henriwoodcock-old