I have trained my model on TPU and result seems good for testing. Dataset has 5 classes and result shows that:
accuracy: 0.9867 - sparse_categorical_accuracy: 0.9867 - loss: 0.0412 - val_accuracy: 0.9859 - val_sparse_categorical_accuracy: 0.9859 - val_loss: 0.0564 - lr: 1.8013e-07
My Sparse Categorical Accuracy Graph
I saved model as .h5 file as described Tensorflow Docs
I loaded TPU_model.h5 using
reconstructed_model = keras.models.load_model("TPU_model.h5"). When I use
reconstructed_model.predict_classes(tensored_image), result is incorrect. Tried reconstructed_model.evaluate, same result. I think about overfitting, tested prediction with image that used on training, result is incorrect.
My latest load and predict code.
reconstructed_model= load_model('TPU_Model_Final.h5')
reconstructed_model= tf.keras.Sequential([reconstructed_model,tf.keras.layers.Softmax()])
reconstructed_model.compile(loss=loss,
optimizer='adam',
metrics=['accuracy','sparse_categorical_accuracy'])
classes = reconstructed_model.predict_classes(images, batch_size=10)
I follwed this tutorial(Tensorflor - Basic classification: Classify images of clothing)
