Search code examples
tensorflowkerasdeep-learningcomputer-visiontraining-data

Why Trained and Loaded Model is giving different evaluate result? 82% vs 5%


I implemented my seq-Keras model and it was successfully trained.

...
model.fit(...)
...
>>Result:  Successfully completed: TrainAcc=99%, ValAcc=88%

Next: NOW I run this code:

model.save('Model88.h5')
model.evaluate(X_test, y_test)
   Result >> accuracy: 0.8216

Next: but when I load the saved model(Model88) and evaluate that:

model = keras.models.load_model('Model88.h5')
model.evaluate(X_test, y_test)
    Result >>  accuracy: 0.0214 !!!

The test data is the same, the saved model and the loaded model are the same!

Why does this happen? accuracy: 82% -> 5% !!!!


Solution

  • I had same problem before and i found out that test accuracy was calculated wrongly during training. I had changed test batch size to 1 to fix it.