Created
October 7, 2019 18:27
-
-
Save monogenea/4ee46d72495ae49aa3ff995e347931a5 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
# Compute probabilities and predictions on test set | |
predictions <- predict_classes(model, test_array) | |
probabilities <- predict_proba(model, test_array) | |
# Visual inspection of 32 cases | |
set.seed(100) | |
random <- sample(1:nrow(testData), 32) | |
preds <- predictions[random,] | |
probs <- as.vector(round(probabilities[random,], 2)) | |
par(mfrow = c(4, 8), mar = rep(0, 4)) | |
for(i in 1:length(random)){ | |
image(t(apply(test_array[random[i],,,], 2, rev)), | |
col = gray.colors(12), axes = F) | |
legend("topright", legend = ifelse(preds[i] == 0, "Cat", "Dog"), | |
text.col = ifelse(preds[i] == 0, 2, 4), bty = "n", text.font = 2) | |
legend("topleft", legend = probs[i], bty = "n", col = "white") | |
} | |
# Save model | |
save(model, file = "CNNmodel.RData") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment