Created
September 20, 2019 08:01
-
-
Save dipanjanS/7ba068d3729ad4eba21c800ffe0c46df to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os | |
| from sklearn.metrics import confusion_matrix, classification_report | |
| import pandas as pd | |
| # save model | |
| if not os.path.isdir('model_weights/'): | |
| os.mkdir('model_weights/') | |
| model.save_weights(filepath='model_weights/cnn_model1_wt.h5', overwrite=True) | |
| # load model (can be used in the future as needed once trained) | |
| model = create_cnn_architecture_model1(input_shape=INPUT_SHAPE) | |
| model.load_weights('model_weights/cnn_model1_wt.h5') | |
| # predict and evaluate on test dataset | |
| test_images_scaled = test_images_gr / 255. | |
| predictions = model.predict(test_images_scaled) | |
| prediction_labels = np.argmax(predictions, axis=1) | |
| print(classification_report(test_labels, prediction_labels, | |
| target_names=class_names)) | |
| pd.DataFrame(confusion_matrix(test_labels, prediction_labels), | |
| index=class_names, columns=class_names) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment