Now, we will evaluate the performance of this model for the training and test data. Calculations relating to the loss, accuracy, and confusion matrix will be carried out so that we can evaluate the model image's classification performance. We will also obtain the accuracy for each of the 10 categories.
Model evaluation and prediction
Loss, accuracy, and confusion matrix with the training data
The code for obtaining the loss, accuracy, and confusion matrix for the training data is as follows:
# Loss and accuracy
model %>% evaluate(trainx, trainy)
$loss
[1] 1.954347
$acc
[1] 0.8785
# Confusion matrix
pred <- model %>% predict_classes(trainx)
table(Predicted=pred, Actual=data$train$y[1:2000,])
Actual
Predicted...