AutoKeras: Exported then reloaded Classifier model does not predict correctly

269 views Asked by At

UPDATE: As kindly pointed out by @Dr Snoopy in the comments below, I was mistaken in thinking that the matrix from the predict() would show the predicted labels - instead it shows classification probabilities.

Issue:

I am trying out AutoKeras by following the step-by-step instructions in their official export page. Everything went fine until print(predicted_y) produced:

[[7.10387882e-09 5.58982416e-10 3.74930835e-07 ... 9.99997973e-01
  2.01310062e-08 3.60369455e-07]
 [1.85361150e-05 9.04550598e-06 9.99895692e-01 ... 2.75132152e-12
  3.61683783e-06 7.38385242e-10]
 [4.39638507e-06 9.98704195e-01 1.83042779e-04 ... 3.79047066e-04
  8.97390855e-05 2.85495821e-06]
 ...
 [2.76643597e-09 3.89823036e-08 2.50714938e-09 ... 1.26030145e-05
  4.11345856e-04 1.28301617e-04]
 [1.66736356e-07 1.93144473e-10 1.16833530e-08 ... 4.25922603e-10
  3.32917640e-04 2.25114619e-07]
 [1.36902031e-06 2.86963953e-10 1.59475476e-05 ... 1.64523464e-11
  2.79402485e-07 4.60360372e-09]]

I then tried print(clf.predict(x_test)) and that gave the correct-looking results:

[['7']
 ['2']
 ['1']
 ...
 ['4']
 ['5']
 ['6']]

My Question:

May I know if anyone else has tried running the code in the AutoKeras export page successfully or hit the same issue as me. If it's the former, I would appreciate any advice on where I did wrong/the issue is. As mentioned, I ran each line of code in the page in the Python console.

Hardware/Software Specs:

OS: Ubuntu 18.04 LTS
GPU: Nvida T4 driver v450.80.02, CUDA v10.1 and cuDNN v7_7.6.5.32
Autokeras==1.0.11
Keras==2.4.3
keras-tuner==1.0.2rc4
tensorboard==2.4.0
tensorboard-plugin-wit==1.7.0
tensorflow==2.3.1
tensorflow-addons==0.11.2
tensorflow-datasets==4.1.0
tensorflow-estimator==2.3.0
tensorflow-hub==0.10.0
tensorflow-metadata==0.25.0
tensorflow-model-optimization==0.5.0
scikit-learn==0.23.2
numpy==1.18.5
pandas==1.1.4

Research Done: So far, I've only found this but that SO question/issue is not the same as mine. I also tried exporting a regression model, reloaded and used it to make the prediction - there was no issue. So I'm surmising the issue is limited to Classification models.

Thanks in advance!

0

There are 0 answers