microsoft / onnxruntime

ONNX Runtime: cross-platform, high performance ML inferencing and training accelerator
https://onnxruntime.ai
MIT License
14.84k stars 2.94k forks source link

Wrong model prediction for keras application models NASNetMobile and NASNetLarge #404

Closed jiafatom closed 5 years ago

jiafatom commented 5 years ago

Describe the bug I am converting keras application models https://github.com/onnx/keras-onnx. (1) I use onnx runtime release 0.1.4, it can convert the keras model (NASNetMobile and NASNetLarge) to onnx model, but it gives me the wrong prediction. For NASNetMobile, all predictions are NAN, for NASNetLarge, most of them are 0.0. (2) I check out the release 0.1.4 and build it locally on my machine using "build.bat --config RelWithDebInfo --build_wheel --enable_pybind", it gives me the correct prediction. So the official release fails on this prediction.

System information

To Reproduce Describe steps/code to reproduce the behavior: Put the following code into keras-onnx/tests/test_layer.py, then run unit tests.

def test_NASNetMobile(self):
    from keras.applications.nasnet import NASNetMobile
    model = NASNetMobile(include_top=True, weights='imagenet')
    self._test_keras_model(model)

def test_NASNetLarge(self):
    from keras.applications.nasnet import NASNetLarge
    model = NASNetLarge(include_top=True, weights='imagenet')
    self._test_keras_model(model, img_size=331)

Expected behavior A clear and concise description of what you expected to happen. Should be a real-value 1*1000 vector which is probability (sum to 1)

Screenshots If applicable, add screenshots to help explain your problem.

Additional context Add any other context about the problem here.

snnn commented 5 years ago

I have nas models from TF, they work fine. nasnet_mobile/nasnet_large/pnasnet_large

snnn commented 5 years ago

You can get the test models from: https://onnxruntimetestdata.blob.core.windows.net/models/20190107.zip

Ref: https://github.com/Microsoft/onnxruntime/blob/master/tools/ci_build/github/azure-pipelines/templates/set-test-data-variables-step.yml

jiafatom commented 5 years ago

Just tested with latest code, it works. Thanks :)