gmalivenko / pytorch2keras

PyTorch to Keras model convertor
https://pytorch2keras.readthedocs.io/en/latest/
MIT License
857 stars 143 forks source link

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

Open YangMingJerry opened 4 years ago

YangMingJerry commented 4 years ago

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):

Additional context Add any other context about the problem here.

henriwoodcock-old commented 3 years ago

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)
AzazelHD commented 3 years ago

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 :(

henriwoodcock-old commented 3 years ago

@AzazelHD I think that's an Onnx2Keras issue.