Skip to content Skip to sidebar Skip to footer

Getting Wrong Prediction With Custom Model After Loading Save Model In Tensorflow.js

After compiling and training my custom model, I saved it and got two files such as .bin and .json. Further, I loaded that custom model on another page where I'm giving images as in

Solution 1:

The model is giving wrong prediction. What to do ?

  • check the accuracy of the model. A very low accuracy of the model will indicate that the model is either not the right one for the problem solved or that some parameters needs to be changed.

  • even if the accuracy is good the model can be wrong in predicting a particular class. In that case, the confusion matrix will be of a great help identify the classes incorrectly predicted. When those classes are identified, one can use more training data for those classes to improve their accuracy after the training


Looking at the model of the question it is clearly obvious that it is a classification model ie given an image, the model will predict the class the image belongs to.

'meanSquaredError' loss is not the best loss function for classification problem. categoricalCrossEntropy will achieve best accuracy. Even after changing the loss function, the accuracy might still not be what is expected. Then one needs to add more layers, change other parameters of the model. Then one will train and compare the accuracy, and the cycle goes on...

Post a Comment for "Getting Wrong Prediction With Custom Model After Loading Save Model In Tensorflow.js"